LifetimeContext LifetimeContext LifetimeContext LifetimeContext Class

定義

代表在存留期樹狀中的節點。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
繼承
實作

備註

LifetimeContext物件是共用的共用組件的單位。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. 繫結的組件執行個體設定為中在鎖定下Dispose()方法。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. 繫結的組件上的 dispose 方法呼叫外部鎖定。The dispose method on a bound part is called outside of the lock.

方法

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()

取得目前執行個體的 TypeGets the Type of the current instance.

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

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

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

傳回此 LifetimeContext 物件的字串表示。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)

傳回符合指定之類型的匯出,如果找不到相符項目則傳回 nullReturns 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)

傳回符合指定之合約名稱及類型的匯出,如果找不到相符項目則傳回 nullReturns 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)

傳回符合指定之泛型類型參數及合約名稱的匯出,如果找不到相符項目則傳回 nullReturns 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)

傳回符合指定之泛型類型參數的匯出,如果找不到相符項目則傳回 nullReturns 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.

適用於