ExportProvider.GetExportedValue 方法

定义

获取一个导出的对象。Gets an exported object.

重载

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)

返回具有指定的协定名称的已导出对象。Returns the exported object with the specified contract name. 如果不是正好有一个匹配的已导出对象,则将引发异常。If there is not exactly one matching exported object, an exception is thrown.

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

具有从指定的类型参数派生的协定名称的已导出对象。The exported object with the contract name derived from the specified type parameter.

例外

有零个已导出对象具有从 CompositionContainer 中的 T 派生的协定名称。There are zero exported objects with the contract name derived from T in the CompositionContainer.

- 或 --or- 有多个已导出对象具有从 CompositionContainer 中的 T 派生的协定名称。There is more than one exported object with the contract name derived from T in the CompositionContainer.

CompositionContainer 对象已被释放。The CompositionContainer object has been disposed of.

不能将基础导出对象强制转换为 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 TThe 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)

返回具有指定的协定名称的已导出对象。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);
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

要返回的已导出对象的协定名称,或者为 null 或空字符串 ("") 以使用默认的协定名称。The contract name of the exported object to return, or null or an empty string ("") to use the default contract name.

返回

T

具有指定的协定名称的已导出对象。The exported object with the specified contract name.

例外

有零个已导出对象具有从 CompositionContainer 中的 T 派生的协定名称。There are zero exported objects with the contract name derived from T in the CompositionContainer.

- 或 --or- 有多个已导出对象具有从 CompositionContainer 中的 T 派生的协定名称。There is more than one exported object with the contract name derived from T in the CompositionContainer.

CompositionContainer 对象已被释放。The CompositionContainer object has been disposed of.

不能将基础导出对象强制转换为 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 TThe 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.

适用于