LifetimeContext LifetimeContext LifetimeContext LifetimeContext Class

Definition

Represents a node in the lifetime tree.

public ref class LifetimeContext sealed : System::Composition::CompositionContext, IDisposable
public sealed class LifetimeContext : System.Composition.CompositionContext, IDisposable
type LifetimeContext = class
    inherit CompositionContext
    interface IDisposable
Public NotInheritable Class LifetimeContext
Inherits CompositionContext
Implements IDisposable
Inheritance
Implements

Remarks

The LifetimeContext object is the unit of sharing for shared parts. It controls the disposal of bound parts and can be used to retrieve instances, either as part of an existing composition operation or as the basis of a new composition operation. An individual lifetime context can be marked to contain parts that are constrained by particular sharing boundaries.

This object contains two pieces of independently protected shared state: shared part instances and bound part instances. A shared part instance is lock-free, readable, and does not result in issues if it is added to during disposal. It is protected by being locked itself. Activation logic is unavoidably called under this lock. A bound part instance is always protected by locking , and should never be written to after disposal. A bound part instance is set to under a lock in the Dispose() method. If writing were allowed after disposal for a bound part instance, it would result in disposable parts not being released. The dispose method on a bound part is called outside of the lock.

Methods

AddBoundInstance(IDisposable) AddBoundInstance(IDisposable) AddBoundInstance(IDisposable) AddBoundInstance(IDisposable)

Binds the lifetime of a disposable part to this lifetime context.

AllocateSharingId() AllocateSharingId() AllocateSharingId() AllocateSharingId()

Generates an identifier that can be used to locate shared part instances.

Dispose() Dispose() Dispose() Dispose()

Releases the lifetime context and any part instances bound to it.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
FindContextWithin(String) FindContextWithin(String) FindContextWithin(String) FindContextWithin(String)

Finds the broadest lifetime context within all of the specified sharing boundaries.

GetExport(CompositionContract) GetExport(CompositionContract) GetExport(CompositionContract) GetExport(CompositionContract)

Retrieves the export that matches the specified contract.

(Inherited from CompositionContext)
GetExport(Type) GetExport(Type) GetExport(Type) GetExport(Type)

Retrieves the export that matches the specified type.

(Inherited from CompositionContext)
GetExport(Type, String) GetExport(Type, String) GetExport(Type, String) GetExport(Type, String)

Retrieves the export that matches the specified name and type.

(Inherited from CompositionContext)
GetExport<TExport>() GetExport<TExport>() GetExport<TExport>() GetExport<TExport>()

Retrieves the export that matches the specified generic type parameter.

(Inherited from CompositionContext)
GetExport<TExport>(String) GetExport<TExport>(String) GetExport<TExport>(String) GetExport<TExport>(String)

Retrieves the export that matches the specified generic type parameter and contract name.

(Inherited from CompositionContext)
GetExports(Type) GetExports(Type) GetExports(Type) GetExports(Type)

Retrieves a collection of all exports that match the specified type.

(Inherited from CompositionContext)
GetExports(Type, String) GetExports(Type, String) GetExports(Type, String) GetExports(Type, String)

Retrieves all exports that match the specified contract name and type.

(Inherited from CompositionContext)
GetExports<TExport>() GetExports<TExport>() GetExports<TExport>() GetExports<TExport>()

Retrieves all exports that match the specified generic type parameter.

(Inherited from CompositionContext)
GetExports<TExport>(String) GetExports<TExport>(String) GetExports<TExport>(String) GetExports<TExport>(String)

Retrieves all exports that match the specified generic type parameter and contract name.

(Inherited from CompositionContext)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetOrCreate(Int32, CompositionOperation, CompositeActivator) GetOrCreate(Int32, CompositionOperation, CompositeActivator) GetOrCreate(Int32, CompositionOperation, CompositeActivator) GetOrCreate(Int32, CompositionOperation, CompositeActivator)

Retrieves a shared part instance with the specified ID, or if the part instance can not be found, creates and shares a part instance using the specified creator within the specified operation.

GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Returns the string representation of this LifetimeContext object.

TryGetExport(CompositionContract, Object) TryGetExport(CompositionContract, Object) TryGetExport(CompositionContract, Object) TryGetExport(CompositionContract, Object)

Retrieves a contract instance from the composition context.

TryGetExport(Type, Object) TryGetExport(Type, Object) TryGetExport(Type, Object) TryGetExport(Type, Object)

Returns the export that matches the specified type, or returns null if no match is found.

(Inherited from CompositionContext)
TryGetExport(Type, String, Object) TryGetExport(Type, String, Object) TryGetExport(Type, String, Object) TryGetExport(Type, String, Object)

Returns the export that matches the specified contract name and type, or returns null if no match is found.

(Inherited from CompositionContext)
TryGetExport<TExport>(String, TExport) TryGetExport<TExport>(String, TExport) TryGetExport<TExport>(String, TExport) TryGetExport<TExport>(String, TExport)

Returns the export that matches the specified generic type parameter and contract name, or returns null if no match is found.

(Inherited from CompositionContext)
TryGetExport<TExport>(TExport) TryGetExport<TExport>(TExport) TryGetExport<TExport>(TExport) TryGetExport<TExport>(TExport)

Returns the export that matches the specified generic type parameter, or returns null if no match is found.

(Inherited from CompositionContext)

Extension Methods

SatisfyImports(CompositionContext, Object) SatisfyImports(CompositionContext, Object) SatisfyImports(CompositionContext, Object) SatisfyImports(CompositionContext, Object)

Satisfies the imports of the specified object from the specified context.

SatisfyImports(CompositionContext, Object, AttributedModelProvider) SatisfyImports(CompositionContext, Object, AttributedModelProvider) SatisfyImports(CompositionContext, Object, AttributedModelProvider) SatisfyImports(CompositionContext, Object, AttributedModelProvider)

Satisfies the imports of the specified object from the specified context, using the specified conventions.

Applies to