Compartilhar via


GlobalObjectService Class

Maintains the current table of global object providers. This class cannot be inherited.

This API is not CLS-compliant. 

Inheritance Hierarchy

Object
  Microsoft.VisualStudio.Shell.Design.GlobalObjectService

Namespace:  Microsoft.VisualStudio.Shell.Design
Assembly:  Microsoft.VisualStudio.Shell.Design (in Microsoft.VisualStudio.Shell.Design.dll)

Syntax

'Declaration
<CLSCompliantAttribute(False)> _
Public NotInheritable Class GlobalObjectService _
    Implements IDisposable
[CLSCompliantAttribute(false)]
public sealed class GlobalObjectService : IDisposable
[CLSCompliantAttribute(false)]
public ref class GlobalObjectService sealed : IDisposable
[<Sealed>]
[<CLSCompliantAttribute(false)>]
type GlobalObjectService =  
    class 
        interface IDisposable 
    end
public final class GlobalObjectService implements IDisposable

The GlobalObjectService type exposes the following members.

Constructors

  Name Description
Public method GlobalObjectService Initializes an new instance of the GlobalObjectService class

Top

Methods

  Name Description
Public method Equals Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public method GetGlobalObjects() Returns a collection of all the currently available global objects.
Public method GetGlobalObjects(Type) Returns a collection of currently available global objects that are of the specified type.
Public method GetGlobalTypes Returns a collection of currently available global types.
Public method GetHashCode Serves as the default hash function. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Explicit Interface Implementations

  Name Description
Explicit interface implemetationPrivate method IDisposable.Dispose Disposes GlobalObjectService.

Top

Remarks

The GlobalObjectService class is queried by design-time tools to obtain information about available global objects and types. The GetGlobalObjects and GetGlobalTypes methods return collections containing the currently available global objects and global types, respectively. GlobalObjectService is commonly queried by the objects of type IReferenceService and ITypeResolutionService.

When the designer loader is initialized, it creates a single instance of the global object service which it associates with the design surface. With this arrangement, global objects can be persisted flexibly, using an arbitrary serialization scheme. Internally, the global object service performs the following duties:

  • It queries the various global object providers for global objects. Each global object returned is queried for a compatible serializer, and if none is found, that global object is discarded because it cannot be serialized.

  • It maintains a table of global objects. This table tracks which global objects came from which provider. After a global object is added to the table, the global object service listens for events on the global object.

  • When a global object’s instance is created, it adds metadata to the instance so it can be serialized. The serializer is obtained by a call to GetSerializer on the global object itself.

  • It monitors the change events for each global object. When a change event is raised the global object service raises an AssemblyObsolete event to the dynamic type service for each unique assembly. It passes an array of types into the event as well, so those listening know exactly what types are valid. This list is built up in two passes in response to the Changing and Changed events. The CodeDomDesignerLoader monitors AssemblyObsolete events and reloads the designer if the assembly contained within the event is being used by the designer.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

Microsoft.VisualStudio.Shell.Design Namespace

GlobalObject

GlobalType

GlobalObjectProvider

GlobalObjectProviderFactory

IReferenceService

ITypeResolutionService

CodeDomDesignerLoader