Table of Contents

Class PartDiscovery

Namespace
Microsoft.VisualStudio.Composition
Assembly
Microsoft.VisualStudio.Composition.dll
public abstract class PartDiscovery
Inheritance
PartDiscovery
Derived
Inherited Members

Constructors

PartDiscovery(Resolver)

protected PartDiscovery(Resolver resolver)

Parameters

resolver Resolver

Properties

Resolver

public Resolver Resolver { get; }

Property Value

Resolver

Methods

AddElement(Array?, object?, Type?)

Creates an array that contains the contents of a prior array (if any) and one additional element.

protected static Array AddElement(Array? priorArray, object? value, Type? elementType)

Parameters

priorArray Array

The previous version of the array. May be null. This will not be modified by this method.

value object

The value to add to the array. May be null.

elementType Type

The element type for the array, if it is created fresh. May be null.

Returns

Array

A new array.

Combine(params PartDiscovery[])

Creates an aggregate PartDiscovery instance that delegates to a series of other part discovery extensions. The DefaultInstance is used.

public static PartDiscovery Combine(params PartDiscovery[] discoveryMechanisms)

Parameters

discoveryMechanisms PartDiscovery[]

The discovery extensions to use. In some cases, extensions defined earlier in the list are preferred.

Returns

PartDiscovery

The aggregate PartDiscovery instance.

Combine(Resolver, params PartDiscovery[])

Creates an aggregate PartDiscovery instance that delegates to a series of other part discovery extensions.

public static PartDiscovery Combine(Resolver resolver, params PartDiscovery[] discoveryMechanisms)

Parameters

resolver Resolver

The Resolver that the aggregate PartDiscovery instance should use.

discoveryMechanisms PartDiscovery[]

The discovery extensions to use. In some cases, extensions defined earlier in the list are preferred.

Returns

PartDiscovery

The aggregate PartDiscovery instance.

CreatePart(Type)

Reflects on a type and returns metadata on its role as a MEF part, if applicable.

public ComposablePartDefinition? CreatePart(Type partType)

Parameters

partType Type

The type to reflect over.

Returns

ComposablePartDefinition

A new instance of ComposablePartDefinition if partType represents a MEF part; otherwise null.

CreatePart(Type, bool)

Reflects on a type and returns metadata on its role as a MEF part, if applicable.

protected abstract ComposablePartDefinition? CreatePart(Type partType, bool typeExplicitlyRequested)

Parameters

partType Type

The type to reflect over.

typeExplicitlyRequested bool

A value indicating whether this type was explicitly requested for inclusion in the catalog.

Returns

ComposablePartDefinition

A new instance of ComposablePartDefinition if partType represents a MEF part; otherwise null.

CreatePartsAsync(IEnumerable<Assembly>, IProgress<DiscoveryProgress>?, CancellationToken)

Reflects over a set of assemblies and produces MEF parts for every applicable type.

public Task<DiscoveredParts> CreatePartsAsync(IEnumerable<Assembly> assemblies, IProgress<DiscoveryProgress>? progress = null, CancellationToken cancellationToken = default)

Parameters

assemblies IEnumerable<Assembly>

The assemblies to search for MEF parts.

progress IProgress<DiscoveryProgress>

An optional way to receive progress updates on how discovery is progressing.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<DiscoveredParts>

A set of generated parts.

CreatePartsAsync(IEnumerable<string>, IProgress<DiscoveryProgress>?, CancellationToken)

Reflects over a set of assemblies and produces MEF parts for every applicable type.

public Task<DiscoveredParts> CreatePartsAsync(IEnumerable<string> assemblyPaths, IProgress<DiscoveryProgress>? progress = null, CancellationToken cancellationToken = default)

Parameters

assemblyPaths IEnumerable<string>

The paths to assemblies to search for MEF parts.

progress IProgress<DiscoveryProgress>

An optional way to receive progress updates on how discovery is progressing.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<DiscoveredParts>

A set of generated parts.

CreatePartsAsync(IEnumerable<Type>, CancellationToken)

public Task<DiscoveredParts> CreatePartsAsync(IEnumerable<Type> partTypes, CancellationToken cancellationToken = default)

Parameters

partTypes IEnumerable<Type>
cancellationToken CancellationToken

Returns

Task<DiscoveredParts>

CreatePartsAsync(Assembly, CancellationToken)

Reflects over an assembly and produces MEF parts for every applicable type.

public Task<DiscoveredParts> CreatePartsAsync(Assembly assembly, CancellationToken cancellationToken = default)

Parameters

assembly Assembly

The assembly to search for MEF parts.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<DiscoveredParts>

A set of generated parts.

CreatePartsAsync(params Type[])

public Task<DiscoveredParts> CreatePartsAsync(params Type[] partTypes)

Parameters

partTypes Type[]

Returns

Task<DiscoveredParts>

GetContractName(Type)

protected static string GetContractName(Type type)

Parameters

type Type

Returns

string

GetElementTypeFromMany(Type)

protected static Type GetElementTypeFromMany(Type type)

Parameters

type Type

Returns

Type

GetExportTypeIdentityConstraints(Type)

protected static ImmutableHashSet<IImportSatisfiabilityConstraint> GetExportTypeIdentityConstraints(Type contractType)

Parameters

contractType Type

Returns

ImmutableHashSet<IImportSatisfiabilityConstraint>

GetImportMetadataForGenericTypeImport(Type)

protected static ImmutableDictionary<string, object?> GetImportMetadataForGenericTypeImport(Type contractType)

Parameters

contractType Type

Returns

ImmutableDictionary<string, object>

GetImportingConstructor<TImportingConstructorAttribute>(Type, bool)

protected static ConstructorInfo? GetImportingConstructor<TImportingConstructorAttribute>(Type type, bool publicOnly) where TImportingConstructorAttribute : Attribute

Parameters

type Type
publicOnly bool

Returns

ConstructorInfo

Type Parameters

TImportingConstructorAttribute

GetImportingSiteTypeWithoutCollection(ImportDefinition, Type)

protected static Type GetImportingSiteTypeWithoutCollection(ImportDefinition importDefinition, Type importingSiteType)

Parameters

importDefinition ImportDefinition
importingSiteType Type

Returns

Type

GetMetadataViewConstraints(Type, bool)

protected ImmutableHashSet<IImportSatisfiabilityConstraint> GetMetadataViewConstraints(Type receivingType, bool importMany)

Parameters

receivingType Type
importMany bool

Returns

ImmutableHashSet<IImportSatisfiabilityConstraint>

GetTypeIdentityFromImportingType(Type, bool)

protected static Type GetTypeIdentityFromImportingType(Type type, bool importMany)

Parameters

type Type
importMany bool

Returns

Type

GetTypeIdentityFromImportingTypeRef(TypeRef, bool)

protected static TypeRef GetTypeIdentityFromImportingTypeRef(TypeRef typeRef, bool importMany)

Parameters

typeRef TypeRef
importMany bool

Returns

TypeRef

GetTypes(Assembly)

Gets the types to consider for MEF parts.

protected abstract IEnumerable<Type> GetTypes(Assembly assembly)

Parameters

assembly Assembly

The assembly to read.

Returns

IEnumerable<Type>

A sequence of types.

IsExportFactoryType(Type)

public abstract bool IsExportFactoryType(Type type)

Parameters

type Type

Returns

bool

ThrowOnInvalidExportingMember(ICustomAttributeProvider)

Throws an exception if certain basic rules for an exporting member are violated.

protected virtual void ThrowOnInvalidExportingMember(ICustomAttributeProvider member)

Parameters

member ICustomAttributeProvider

The exporting member (or type).

ThrowOnInvalidImportingMemberOrParameter(ICustomAttributeProvider, bool)

Throws an exception if certain basic rules for an importing member or parameter are violated.

protected virtual void ThrowOnInvalidImportingMemberOrParameter(ICustomAttributeProvider member, bool isImportMany)

Parameters

member ICustomAttributeProvider

The importing member or importing parameter.

isImportMany bool

A value indicating whether the import is an ImportMany.