Κοινή χρήση μέσω


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
LifetimeContext
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 this, and should never be written to after disposal. A bound part instance is set to null 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)

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

AllocateSharingId()

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

Dispose()

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

Equals(Object)

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

(Inherited from Object)
FindContextWithin(String)

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

GetExport(CompositionContract)

Retrieves the export that matches the specified contract.

(Inherited from CompositionContext)
GetExport(Type, String)

Retrieves the export that matches the specified name and type.

(Inherited from CompositionContext)
GetExport(Type)

Retrieves the export that matches the specified type.

(Inherited from CompositionContext)
GetExport<TExport>()

Retrieves the export that matches the specified generic type parameter.

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

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

(Inherited from CompositionContext)
GetExports(Type, String)

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

(Inherited from CompositionContext)
GetExports(Type)

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

(Inherited from CompositionContext)
GetExports<TExport>()

Retrieves all exports that match the specified generic type parameter.

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

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

(Inherited from CompositionContext)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
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()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns the string representation of this LifetimeContext object.

TryGetExport(CompositionContract, Object)

Retrieves a contract instance from the composition context.

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)

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)

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)

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, AttributedModelProvider)

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

SatisfyImports(CompositionContext, Object)

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

Applies to