ExportProvider.GetExportedValue ExportProvider.GetExportedValue ExportProvider.GetExportedValue ExportProvider.GetExportedValue Method

定義

取得匯出的物件。Gets an exported object.

多載

GetExportedValue<T>() GetExportedValue<T>() GetExportedValue<T>() GetExportedValue<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.

GetExportedValue<T>(String) GetExportedValue<T>(String) GetExportedValue<T>(String) GetExportedValue<T>(String)

傳回具有指定合約名稱的匯出物件。Returns the exported object with the specified contract name. 如果沒有一個完全相符的匯出物件,則會擲回例外狀況。If there is not exactly one matching exported object, an exception is thrown.

GetExportedValue<T>() GetExportedValue<T>() GetExportedValue<T>() GetExportedValue<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.

public:
generic <typename T>
 T GetExportedValue();
public T GetExportedValue<T> ();
member this.GetExportedValue : unit -> 'T
Public Function GetExportedValue(Of T) () As T

類型參數

T

要傳回之已匯出的物件型別。The type of the exported object to return. 合約名稱也是從這個型別參數衍生。The contract name is also derived from this type parameter.

傳回

T T T T

具有從指定型別參數中衍生之合約名稱的匯出物件。The exported object with the contract name derived from the specified type parameter.

例外狀況

沒有任何具有合約名稱的匯出物件衍生自 CompositionContainer 中的 TThere are zero exported objects with the contract name derived from T in the CompositionContainer.

-或--or- 有一個以上具有合約名稱的匯出物件衍生自 CompositionContainer 中的 TThere is more than one exported object with the contract name derived from T in the CompositionContainer.

基礎的匯出物件無法轉換成 TThe underlying exported object cannot be cast to T.

在撰寫期間發生錯誤。An error occurred during composition. Errors 將包含發生之錯誤的集合。Errors will contain a collection of errors that occurred.

備註

合約名稱是在上GetContractName T呼叫方法的結果。The contract name is the result of calling the GetContractName method on T.

合約名稱的比較方式是使用Ordinal屬性來執行區分大小寫的非語言比較。The contract name is compared by using the Ordinal property to perform a case-sensitive, non-linguistic comparison.

GetExportedValue<T>(String) GetExportedValue<T>(String) GetExportedValue<T>(String) GetExportedValue<T>(String)

傳回具有指定合約名稱的匯出物件。Returns the exported object with the specified contract name. 如果沒有一個完全相符的匯出物件,則會擲回例外狀況。If there is not exactly one matching exported object, an exception is thrown.

public:
generic <typename T>
 T GetExportedValue(System::String ^ contractName);
public T GetExportedValue<T> (string contractName);
member this.GetExportedValue : string -> 'T
Public Function GetExportedValue(Of T) (contractName As String) As T

類型參數

T

要傳回之已匯出的物件型別。The type of the exported object to return.

參數

contractName
String String String String

要傳回的匯出物件的合約名稱,或者是 null,或者是要使用預設合約名稱的空字串 ("")。The contract name of the exported object to return, or null or an empty string ("") to use the default contract name.

傳回

T T T T

具有指定合約名稱的匯出物件。The exported object with the specified contract name.

例外狀況

沒有任何具有合約名稱的匯出物件衍生自 CompositionContainer 中的 TThere are zero exported objects with the contract name derived from T in the CompositionContainer.

-或--or- 有一個以上具有合約名稱的匯出物件衍生自 CompositionContainer 中的 TThere is more than one exported object with the contract name derived from T in the CompositionContainer.

基礎的匯出物件無法轉換成 TThe underlying exported object cannot be cast to T.

在撰寫期間發生錯誤。An error occurred during composition. Errors 將包含發生之錯誤的集合。Errors will contain a collection of errors that occurred.

備註

預設的合約名稱是在上GetContractName T呼叫方法的結果。The default contract name is the result of calling the GetContractName method on T.

合約名稱的比較方式是使用Ordinal屬性來執行區分大小寫的非語言比較。The contract name is compared by using the Ordinal property to perform a case-sensitive, non-linguistic comparison.

適用於