LifetimeContext 類別

定義

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

備註

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. 啟用邏輯會在此鎖定下呼叫 unavoidably。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)

將可處置部分的存留期繫結至這個存留期內容。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.

(繼承來源 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.

(繼承來源 CompositionContext)
GetExport(Type)

擷取符合指定類型的匯出。Retrieves the export that matches the specified type.

(繼承來源 CompositionContext)
GetExport(Type, String)

擷取符合指定名稱與類型的匯出。Retrieves the export that matches the specified name and type.

(繼承來源 CompositionContext)
GetExport<TExport>()

擷取符合指定泛型型別參數的匯出。Retrieves the export that matches the specified generic type parameter.

(繼承來源 CompositionContext)
GetExport<TExport>(String)

擷取符合指定泛型型別參數與合約名稱的匯出。Retrieves the export that matches the specified generic type parameter and contract name.

(繼承來源 CompositionContext)
GetExports(Type)

擷取符合指定類型之所有匯出的集合。Retrieves a collection of all exports that match the specified type.

(繼承來源 CompositionContext)
GetExports(Type, String)

擷取符合指定合約名稱與類型的所有匯出。Retrieves all exports that match the specified contract name and type.

(繼承來源 CompositionContext)
GetExports<TExport>()

擷取符合指定泛型型別參數的所有匯出。Retrieves all exports that match the specified generic type parameter.

(繼承來源 CompositionContext)
GetExports<TExport>(String)

擷取符合指定泛型型別參數與合約名稱的所有匯出。Retrieves all exports that match the specified generic type parameter and contract name.

(繼承來源 CompositionContext)
GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 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()

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

(繼承來源 Object)
MemberwiseClone()

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

(繼承來源 Object)
ToString()

傳回此 LifetimeContext 物件的字串表示。Returns the string representation of this LifetimeContext object.

TryGetExport(CompositionContract, Object)

從組合內容擷取合約執行個體。Retrieves a contract instance from the composition context.

TryGetExport(Type, Object)

傳回符合指定之類型的匯出,如果找不到相符項目則傳回 nullReturns the export that matches the specified type, or returns null if no match is found.

(繼承來源 CompositionContext)
TryGetExport(Type, String, Object)

傳回符合指定之合約名稱及類型的匯出,如果找不到相符項目則傳回 nullReturns the export that matches the specified contract name and type, or returns null if no match is found.

(繼承來源 CompositionContext)
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.

(繼承來源 CompositionContext)
TryGetExport<TExport>(TExport)

傳回符合指定之泛型類型參數的匯出,如果找不到相符項目則傳回 nullReturns the export that matches the specified generic type parameter, or returns null if no match is found.

(繼承來源 CompositionContext)

擴充方法

SatisfyImports(CompositionContext, Object)

符合來自指定內容之指定物件的匯入。Satisfies the imports of the specified object from the specified context.

SatisfyImports(CompositionContext, Object, AttributedModelProvider)

使用指定的慣例,符合來自指定內容之指定物件的匯入。Satisfies the imports of the specified object from the specified context, using the specified conventions.

適用於