ExportProvider.GetExportedValueOrDefault ExportProvider.GetExportedValueOrDefault ExportProvider.GetExportedValueOrDefault ExportProvider.GetExportedValueOrDefault Method

Definition

Gets a specified exported object or a default value if it is unavailable.

Overloads

GetExportedValueOrDefault<T>() GetExportedValueOrDefault<T>() GetExportedValueOrDefault<T>() GetExportedValueOrDefault<T>()

Gets the exported object with the contract name derived from the specified type parameter or the default value for the specified type, or throws an exception if there is more than one matching exported object.

GetExportedValueOrDefault<T>(String) GetExportedValueOrDefault<T>(String) GetExportedValueOrDefault<T>(String) GetExportedValueOrDefault<T>(String)

Gets the exported object with the specified contract name or the default value for the specified type, or throws an exception if there is more than one matching exported object.

GetExportedValueOrDefault<T>() GetExportedValueOrDefault<T>() GetExportedValueOrDefault<T>() GetExportedValueOrDefault<T>()

Gets the exported object with the contract name derived from the specified type parameter or the default value for the specified type, or throws an exception if there is more than one matching exported object.

public:
generic <typename T>
 T GetExportedValueOrDefault();
public T GetExportedValueOrDefault<T> ();
member this.GetExportedValueOrDefault : unit -> 'T
Public Function GetExportedValueOrDefault(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 T T T

The exported object with the contract name derived from T, if found; otherwise, the default value for T.

Exceptions

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

Remarks

If the exported object is not found, this method returns the appropriate default value for T; for example, zero for integer types, false for Boolean types, and null for reference types.

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.

GetExportedValueOrDefault<T>(String) GetExportedValueOrDefault<T>(String) GetExportedValueOrDefault<T>(String) GetExportedValueOrDefault<T>(String)

Gets the exported object with the specified contract name or the default value for the specified type, or throws an exception if there is more than one matching exported object.

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

Type Parameters

T

The type of the exported object to return.

Parameters

contractName
String String String String

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

Returns

T T T T

The exported object with the specified contract name, if found; otherwise, the default value for T.

Exceptions

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

Remarks

If the exported object is not found, this method returns the appropriate default value for T; for example, zero for integer types, false for Boolean types, and null for reference types.

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