CompositionContext.TryGetExport Method

Definition

Overloads

TryGetExport(CompositionContract, Object)

Returns the export that matches the specified contract, or returns null if no match is found.

TryGetExport(Type, Object)

Returns the export that matches the specified type, or returns null if no match is found.

TryGetExport(Type, String, Object)

Returns the export that matches the specified contract name and type, or returns null if no match is found.

TryGetExport<TExport>(TExport)

Returns the export that matches the specified generic type parameter, or returns null if no match is found.

TryGetExport<TExport>(String, TExport)

Returns the export that matches the specified generic type parameter and contract name, or returns null if no match is found.

TryGetExport(CompositionContract, Object)

Source:
CompositionContext.cs
Source:
CompositionContext.cs
Source:
CompositionContext.cs

Returns the export that matches the specified contract, or returns null if no match is found.

C#
public abstract bool TryGetExport(System.Composition.Hosting.Core.CompositionContract contract, out object export);

Parameters

contract
CompositionContract

The contract to match.

export
Object

When this method returns, contains the matched export or null.

Returns

true if an export was found; otherwise, false.

Exceptions

No export was found for contract.

Applies to

.NET 10 (package-provided) 和其他版本
产品 版本
.NET Core 1.1, 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Standard 2.0 (package-provided)

TryGetExport(Type, Object)

Source:
CompositionContext.cs
Source:
CompositionContext.cs
Source:
CompositionContext.cs

Returns the export that matches the specified type, or returns null if no match is found.

C#
public bool TryGetExport(Type exportType, out object export);

Parameters

exportType
Type

The type to match.

export
Object

When this method returns, contains the matched export or null.

Returns

true if an export was found; otherwise, false.

Applies to

.NET 10 (package-provided) 和其他版本
产品 版本
.NET Core 1.1, 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Standard 2.0 (package-provided)

TryGetExport(Type, String, Object)

Source:
CompositionContext.cs
Source:
CompositionContext.cs
Source:
CompositionContext.cs

Returns the export that matches the specified contract name and type, or returns null if no match is found.

C#
public bool TryGetExport(Type exportType, string contractName, out object export);

Parameters

exportType
Type

The type to match.

contractName
String

The name to match.

export
Object

When this method returns, contains the matched export or null.

Returns

true if an export was found; otherwise, false.

Exceptions

No export was found for contractName.

Applies to

.NET 10 (package-provided) 和其他版本
产品 版本
.NET Core 1.1, 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Standard 2.0 (package-provided)

TryGetExport<TExport>(TExport)

Source:
CompositionContext.cs
Source:
CompositionContext.cs
Source:
CompositionContext.cs

Returns the export that matches the specified generic type parameter, or returns null if no match is found.

C#
public bool TryGetExport<TExport>(out TExport export);

Type Parameters

TExport

The type to match.

Parameters

export
TExport

When this method returns, contains the matched export or null.

Returns

true if an export was found; otherwise, false.

Applies to

.NET 10 (package-provided) 和其他版本
产品 版本
.NET Core 1.1, 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Standard 2.0 (package-provided)

TryGetExport<TExport>(String, TExport)

Source:
CompositionContext.cs
Source:
CompositionContext.cs
Source:
CompositionContext.cs

Returns the export that matches the specified generic type parameter and contract name, or returns null if no match is found.

C#
public bool TryGetExport<TExport>(string contractName, out TExport export);

Type Parameters

TExport

The type to match.

Parameters

contractName
String

The name to match.

export
TExport

When this method returns, contains the matched export or null.

Returns

true if an export was found; otherwise, false.

Exceptions

No export was found for contractName.

Applies to

.NET 10 (package-provided) 和其他版本
产品 版本
.NET Core 1.1, 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Standard 2.0 (package-provided)