แก้ไข

แชร์ผ่าน


ExportProvider.GetExportedValue Method

Definition

Gets an exported object.

Overloads

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

Source:
ExportProvider.GetExportOverrides.cs
Source:
ExportProvider.GetExportOverrides.cs
Source:
ExportProvider.GetExportOverrides.cs

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

Type Parameters

T

The type of the exported object to return. The contract name is also derived from this type parameter.

Returns

T

The exported object with the contract name derived from the specified type parameter.

Exceptions

There are zero exported objects with the contract name derived from T in the CompositionContainer.

-or-

There is more than one exported object with the contract name derived from T in the CompositionContainer.

The CompositionContainer object has been disposed of.

The underlying exported object cannot be cast to T.

An error occurred during composition. Errors will contain a collection of errors that occurred.

Remarks

The contract name is the result of calling the GetContractName method on T.

The contract name is compared by using the Ordinal property to perform a case-sensitive, non-linguistic comparison.

Applies to

GetExportedValue<T>(String)

Source:
ExportProvider.GetExportOverrides.cs
Source:
ExportProvider.GetExportOverrides.cs
Source:
ExportProvider.GetExportOverrides.cs

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

Type Parameters

T

The type of the exported object to return.

Parameters

contractName
String

The contract name of the exported object to return, or null or an empty string ("") to use the default contract name.

Returns

T

The exported object with the specified contract name.

Exceptions

There are zero exported objects with the contract name derived from T in the CompositionContainer.

-or-

There is more than one exported object with the contract name derived from T in the CompositionContainer.

The CompositionContainer object has been disposed of.

The underlying exported object cannot be cast to T.

An error occurred during composition. Errors will contain a collection of errors that occurred.

Remarks

The default contract name is the result of calling the GetContractName method on T.

The contract name is compared by using the Ordinal property to perform a case-sensitive, non-linguistic comparison.

Applies to