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
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
ArrayThe previous version of the array. May be null. This will not be modified by this method.
value
objectThe value to add to the array. May be null.
elementType
TypeThe 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
ResolverThe 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
TypeThe 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
TypeThe type to reflect over.
typeExplicitlyRequested
boolA 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
CancellationTokenThe 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
CancellationTokenThe 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
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
AssemblyThe assembly to search for MEF parts.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task<DiscoveredParts>
A set of generated parts.
CreatePartsAsync(params Type[])
public Task<DiscoveredParts> CreatePartsAsync(params Type[] partTypes)
Parameters
partTypes
Type[]
Returns
GetContractName(Type)
protected static string GetContractName(Type type)
Parameters
type
Type
Returns
GetElementTypeFromMany(Type)
protected static Type GetElementTypeFromMany(Type type)
Parameters
type
Type
Returns
GetExportTypeIdentityConstraints(Type)
protected static ImmutableHashSet<IImportSatisfiabilityConstraint> GetExportTypeIdentityConstraints(Type contractType)
Parameters
contractType
Type
Returns
GetImportMetadataForGenericTypeImport(Type)
protected static ImmutableDictionary<string, object?> GetImportMetadataForGenericTypeImport(Type contractType)
Parameters
contractType
Type
Returns
GetImportingConstructor<TImportingConstructorAttribute>(Type, bool)
protected static ConstructorInfo? GetImportingConstructor<TImportingConstructorAttribute>(Type type, bool publicOnly) where TImportingConstructorAttribute : Attribute
Parameters
Returns
Type Parameters
TImportingConstructorAttribute
GetImportingSiteTypeWithoutCollection(ImportDefinition, Type)
protected static Type GetImportingSiteTypeWithoutCollection(ImportDefinition importDefinition, Type importingSiteType)
Parameters
importDefinition
ImportDefinitionimportingSiteType
Type
Returns
GetMetadataViewConstraints(Type, bool)
protected ImmutableHashSet<IImportSatisfiabilityConstraint> GetMetadataViewConstraints(Type receivingType, bool importMany)
Parameters
Returns
GetTypeIdentityFromImportingType(Type, bool)
protected static Type GetTypeIdentityFromImportingType(Type type, bool importMany)
Parameters
Returns
GetTypeIdentityFromImportingTypeRef(TypeRef, bool)
protected static TypeRef GetTypeIdentityFromImportingTypeRef(TypeRef typeRef, bool importMany)
Parameters
Returns
GetTypes(Assembly)
Gets the types to consider for MEF parts.
protected abstract IEnumerable<Type> GetTypes(Assembly assembly)
Parameters
assembly
AssemblyThe assembly to read.
Returns
- IEnumerable<Type>
A sequence of types.
IsExportFactoryType(Type)
public abstract bool IsExportFactoryType(Type type)
Parameters
type
Type
Returns
ThrowOnInvalidExportingMember(ICustomAttributeProvider)
Throws an exception if certain basic rules for an exporting member are violated.
protected virtual void ThrowOnInvalidExportingMember(ICustomAttributeProvider member)
Parameters
member
ICustomAttributeProviderThe 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
ICustomAttributeProviderThe importing member or importing parameter.
isImportMany
boolA value indicating whether the import is an ImportMany.