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
resolverResolver
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
priorArrayArrayThe previous version of the array. May be null. This will not be modified by this method.
valueobjectThe value to add to the array. May be null.
elementTypeTypeThe 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
discoveryMechanismsPartDiscovery[]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
resolverResolverThe Resolver that the aggregate PartDiscovery instance should use.
discoveryMechanismsPartDiscovery[]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
partTypeTypeThe type to reflect over.
Returns
- ComposablePartDefinition
A new instance of ComposablePartDefinition if
partTyperepresents 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
partTypeTypeThe type to reflect over.
typeExplicitlyRequestedboolA value indicating whether this type was explicitly requested for inclusion in the catalog.
Returns
- ComposablePartDefinition
A new instance of ComposablePartDefinition if
partTyperepresents 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
assembliesIEnumerable<Assembly>The assemblies to search for MEF parts.
progressIProgress<DiscoveryProgress>An optional way to receive progress updates on how discovery is progressing.
cancellationTokenCancellationTokenThe 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
assemblyPathsIEnumerable<string>The paths to assemblies to search for MEF parts.
progressIProgress<DiscoveryProgress>An optional way to receive progress updates on how discovery is progressing.
cancellationTokenCancellationTokenThe 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
partTypesIEnumerable<Type>cancellationTokenCancellationToken
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
assemblyAssemblyThe assembly to search for MEF parts.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task<DiscoveredParts>
A set of generated parts.
CreatePartsAsync(params Type[])
public Task<DiscoveredParts> CreatePartsAsync(params Type[] partTypes)
Parameters
partTypesType[]
Returns
GetContractName(Type)
protected static string GetContractName(Type type)
Parameters
typeType
Returns
GetElementTypeFromMany(Type)
protected static Type GetElementTypeFromMany(Type type)
Parameters
typeType
Returns
GetExportTypeIdentityConstraints(Type)
protected static ImmutableHashSet<IImportSatisfiabilityConstraint> GetExportTypeIdentityConstraints(Type contractType)
Parameters
contractTypeType
Returns
GetImportMetadataForGenericTypeImport(Type)
protected static ImmutableDictionary<string, object?> GetImportMetadataForGenericTypeImport(Type contractType)
Parameters
contractTypeType
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
importDefinitionImportDefinitionimportingSiteTypeType
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
assemblyAssemblyThe assembly to read.
Returns
- IEnumerable<Type>
A sequence of types.
IsExportFactoryType(Type)
public abstract bool IsExportFactoryType(Type type)
Parameters
typeType
Returns
ThrowOnInvalidExportingMember(ICustomAttributeProvider)
Throws an exception if certain basic rules for an exporting member are violated.
protected virtual void ThrowOnInvalidExportingMember(ICustomAttributeProvider member)
Parameters
memberICustomAttributeProviderThe 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
memberICustomAttributeProviderThe importing member or importing parameter.
isImportManyboolA value indicating whether the import is an ImportMany.