ExportProvider.GetExportedValue Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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>()
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
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)
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
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
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기