CompositionContainer Class

 

Manages the composition of parts.

Namespace:   System.ComponentModel.Composition.Hosting
Assembly:  System.ComponentModel.Composition (in System.ComponentModel.Composition.dll)

System::Object
  System.ComponentModel.Composition.Hosting::ExportProvider
    System.ComponentModel.Composition.Hosting::CompositionContainer

public ref class CompositionContainer : ExportProvider, ICompositionService, 
	IDisposable

NameDescription
System_CAPS_pubmethodCompositionContainer()

Initializes a new instance of the CompositionContainer class.

System_CAPS_pubmethodCompositionContainer(ComposablePartCatalog^, Boolean, array<ExportProvider^>^)

Initializes a new instance of the CompositionContainer class with the specified catalog, thread-safe mode, and export providers.

System_CAPS_pubmethodCompositionContainer(ComposablePartCatalog^, CompositionOptions, array<ExportProvider^>^)

Initializes a new instance of the CompositionContainer class with the specified catalog, options, and export providers.

System_CAPS_pubmethodCompositionContainer(ComposablePartCatalog^, array<ExportProvider^>^)

Initializes a new instance of the CompositionContainer class with the specified catalog and export providers.

System_CAPS_pubmethodCompositionContainer(CompositionOptions, array<ExportProvider^>^)

Initializes a new instance of the CompositionContainer class with the specified export providers and options.

System_CAPS_pubmethodCompositionContainer(array<ExportProvider^>^)

Initializes a new instance of the CompositionContainer class with the specified export providers.

NameDescription
System_CAPS_pubpropertyCatalog

Gets the ComposablePartCatalog that provides the container access to Export objects.

System_CAPS_pubpropertyProviders

Gets the export providers that provide the container access to additional ComposablePartCatalog objects.

NameDescription
System_CAPS_pubmethodCompose(CompositionBatch^)

Adds or removes the parts in the specified CompositionBatch from the container and executes composition.

System_CAPS_pubmethodDispose()

Releases all resources used by the current instance of the CompositionContainer class.

System_CAPS_protmethodDispose(Boolean)

Releases the unmanaged resources used by the CompositionContainer and optionally releases the managed resources.

System_CAPS_pubmethodEquals(Object^)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetExport<T>()

Returns the export with the contract name derived from the specified type parameter. If there is not exactly one matching export, an exception is thrown.(Inherited from ExportProvider.)

System_CAPS_pubmethodGetExport<T>(String^)

Returns the export with the specified contract name. If there is not exactly one matching export, an exception is thrown.(Inherited from ExportProvider.)

System_CAPS_pubmethodGetExportedValue<T>()

Returns the exported object with the contract name derived from the specified type parameter. If there is not exactly one matching exported object, an exception is thrown.(Inherited from ExportProvider.)

System_CAPS_pubmethodGetExportedValue<T>(String^)

Returns the exported object with the specified contract name. If there is not exactly one matching exported object, an exception is thrown.(Inherited from ExportProvider.)

System_CAPS_pubmethodGetExportedValueOrDefault<T>()

Gets the exported object with the contract name derived from the specified type parameter or the default value for the specified type, or throws an exception if there is more than one matching exported object.(Inherited from ExportProvider.)

System_CAPS_pubmethodGetExportedValueOrDefault<T>(String^)

Gets the exported object with the specified contract name or the default value for the specified type, or throws an exception if there is more than one matching exported object.(Inherited from ExportProvider.)

System_CAPS_pubmethodGetExportedValues<T>()

Gets all the exported objects with the contract name derived from the specified type parameter.(Inherited from ExportProvider.)

System_CAPS_pubmethodGetExportedValues<T>(String^)

Gets all the exported objects with the specified contract name.(Inherited from ExportProvider.)

System_CAPS_pubmethodGetExports(ImportDefinition^)

Gets all exports that match the conditions of the specified import definition.(Inherited from ExportProvider.)

System_CAPS_pubmethodGetExports(ImportDefinition^, AtomicComposition^)

Gets all exports that match the conditions of the specified import definition and composition.(Inherited from ExportProvider.)

System_CAPS_pubmethodGetExports(Type^, Type^, String^)

Gets all the exports with the specified contract name.(Inherited from ExportProvider.)

System_CAPS_pubmethodGetExports<T>()

Gets all the exports with the contract name derived from the specified type parameter.(Inherited from ExportProvider.)

System_CAPS_pubmethodGetExports<T>(String^)

Gets all the exports with the specified contract name.(Inherited from ExportProvider.)

System_CAPS_protmethodGetExportsCore(ImportDefinition^, AtomicComposition^)

Returns a collection of all exports that match the conditions in the specified ImportDefinition object.(Overrides ExportProvider::GetExportsCore(ImportDefinition^, AtomicComposition^).)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_protmethodOnExportsChanged(ExportsChangeEventArgs^)

Raises the ExportsChanged event.(Inherited from ExportProvider.)

System_CAPS_protmethodOnExportsChanging(ExportsChangeEventArgs^)

Raises the ExportsChanging event.(Inherited from ExportProvider.)

System_CAPS_pubmethodReleaseExport(Export^)

Releases the specified Export object from the CompositionContainer.

System_CAPS_pubmethodReleaseExport<T>(Lazy<T>^)

Removes the specified export from composition and releases its resources if possible.

System_CAPS_pubmethodReleaseExports(IEnumerable<Export^>^)

Releases a set of Export objects from the CompositionContainer.

System_CAPS_pubmethodReleaseExports<T>(IEnumerable<Lazy<T>^>^)

Removes a collection of exports from composition and releases their resources if possible.

System_CAPS_pubmethodReleaseExports<T, TMetadataView>(IEnumerable<Lazy<T, TMetadataView>^>^)

Removes a collection of exports from composition and releases their resources if possible.

System_CAPS_pubmethodSatisfyImportsOnce(ComposablePart^)

Satisfies the imports of the specified ComposablePart object without registering it for recomposition.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

System_CAPS_pubmethodTryGetExports(ImportDefinition^, AtomicComposition^, IEnumerable<Export^>^%)

Gets all the exports that match the conditions of the specified import.(Inherited from ExportProvider.)

NameDescription
System_CAPS_pubeventExportsChanged

Occurs when the exports in the ExportProvider change.(Inherited from ExportProvider.)

System_CAPS_pubeventExportsChanging

Occurs when the provided exports are changing.(Inherited from ExportProvider.)

NameDescription
System_CAPS_pubmethodComposeExportedValue<T>(T)

Overloaded. Creates a part from the specified value and composes it in the specified composition container.(Defined by AttributedModelServices.)

System_CAPS_pubmethodComposeExportedValue<T>(String^, T)

Overloaded. Creates a part from the specified object under the specified contract name and composes it in the specified composition container.(Defined by AttributedModelServices.)

System_CAPS_pubmethodComposeParts(array<Object^>^)

Creates composable parts from an array of attributed objects and composes them in the specified composition container.(Defined by AttributedModelServices.)

System_CAPS_pubmethodSatisfyImportsOnce(Object^)

Overloaded. Composes the specified part by using the specified composition service, with recomposition disabled.(Defined by AttributedModelServices.)

System_CAPS_pubmethodSatisfyImportsOnce(Object^, ReflectionContext^)

Overloaded. Composes the specified part by using the specified composition service, with recomposition disabled and using the specified reflection context.(Defined by AttributedModelServices.)

A CompositionContainer object serves two major purposes in an application. First, it keeps track of which parts are available for composition and what their dependencies are, and performs composition whenever the set of available parts changes. Second, it provides the methods by which the application gets instances of composed parts or fills the dependencies of a composable part.

System_CAPS_importantImportant

This type implements the IDisposable interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its Dispose method in a try/catch block. To dispose of it indirectly, use a language construct such as using (in C#) or Using (in Visual Basic). For more information, see the “Using an Object that Implements IDisposable” section in the IDisposable interface topic.

Parts can be made available to the container either directly or through the Catalog property. All the parts discoverable in this ComposablePartCatalog are available to the container to fulfill imports, along with any parts added directly.

The Compose method allows instantiated parts to be added to an existing container. Assuming composition is successful, these parts will have their imports filled with parts retrieved from the container, and their exports will be available to other parts. Imports marked as recomposable will be registered for recomposition.

The SatisfyImportsOnce method allows a part to have its imports filled without being added to the container. If the composition is successful, the part's imports will be filled, but the part's exports will not be available to other parts and no imports will be registered for recomposition.

CompositionContainer objects should always be disposed. When the Dispose method is called, the CompositionContainer object also disposes all the parts that it has created.

A CompositionContainer object that can be accessed from multiple threads must be constructed with the isThreadSafe parameter set to true, using the CompositionContainer(ComposablePartCatalog^, Boolean, array<ExportProvider^>^) constructor. Performance will be slightly slower when isThreadSafe is true, so we recommend that you set this parameter to false in single-threaded scenarios. The default is false.

System_CAPS_warningWarning

A CompositionContainer should never import itself, or a part that has a reference to it. Such a reference could allow an untrusted part to gain access all the parts in the container.

In the following example, a CompositionContainer object is initialized with a catalog and is used to fill the imports of a part. This example uses the Attributed Programming Model.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 4.0
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 4.0

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

Return to top
Show: