Class ExportProvider
- Namespace
- Microsoft.VisualStudio.Composition
- Assembly
- Microsoft.VisualStudio.Composition.dll
public abstract class ExportProvider : IDisposableObservable, IDisposable
- Inheritance
-
ExportProvider
- Implements
- Derived
- Inherited Members
- Extension Methods
Fields
EmptyMetadata
A metadata template used by the generated code.
protected static readonly ImmutableDictionary<string, object?> EmptyMetadata
Field Value
EmptyObjectArray
protected static readonly object[] EmptyObjectArray
Field Value
- object[]
EmptyTypeArray
protected static readonly Type[] EmptyTypeArray
Field Value
- Type[]
NotInstantiablePartLazy
protected static readonly Lazy<object> NotInstantiablePartLazy
Field Value
Properties
NonDisposableWrapper
Gets a lazy that creates an instance of DelegatingExportProvider.
protected Lazy<object> NonDisposableWrapper { get; }
Property Value
NonDisposableWrapperExportAsListOfOne
protected ImmutableList<Export> NonDisposableWrapperExportAsListOfOne { get; }
Property Value
Resolver
protected Resolver Resolver { get; }
Property Value
Methods
CannotInstantiatePartWithNoImportingConstructor()
protected static object CannotInstantiatePartWithNoImportingConstructor()
Returns
CreateExportFactory(Type, IReadOnlyCollection<string>, Func<KeyValuePair<object?, IDisposable?>>, Type, IReadOnlyDictionary<string, object?>)
protected object CreateExportFactory(Type importingSiteElementType, IReadOnlyCollection<string> sharingBoundaries, Func<KeyValuePair<object?, IDisposable?>> valueFactory, Type exportFactoryType, IReadOnlyDictionary<string, object?> exportMetadata)
Parameters
importingSiteElementTypeTypesharingBoundariesIReadOnlyCollection<string>valueFactoryFunc<KeyValuePair<object, IDisposable>>exportFactoryTypeTypeexportMetadataIReadOnlyDictionary<string, object>
Returns
Dispose()
public void Dispose()
Dispose(bool)
protected virtual void Dispose(bool disposing)
Parameters
disposingbool
GetExport<T>()
public Lazy<T> GetExport<T>()
Returns
- Lazy<T>
Type Parameters
T
GetExport<T>(string?)
public Lazy<T> GetExport<T>(string? contractName)
Parameters
contractNamestring
Returns
- Lazy<T>
Type Parameters
T
GetExport<T, TMetadataView>()
public Lazy<T, TMetadataView> GetExport<T, TMetadataView>()
Returns
- Lazy<T, TMetadataView>
Type Parameters
TTMetadataView
GetExport<T, TMetadataView>(string?)
public Lazy<T, TMetadataView> GetExport<T, TMetadataView>(string? contractName)
Parameters
contractNamestring
Returns
- Lazy<T, TMetadataView>
Type Parameters
TTMetadataView
GetExportedValue<T>()
public T GetExportedValue<T>()
Returns
- T
Type Parameters
T
GetExportedValue<T>(string?)
public T GetExportedValue<T>(string? contractName)
Parameters
contractNamestring
Returns
- T
Type Parameters
T
GetExportedValues(Type, string?)
public IEnumerable<object?> GetExportedValues(Type type, string? contractName)
Parameters
Returns
GetExportedValues<T>()
public IEnumerable<T> GetExportedValues<T>()
Returns
- IEnumerable<T>
Type Parameters
T
GetExportedValues<T>(string?)
public IEnumerable<T> GetExportedValues<T>(string? contractName)
Parameters
contractNamestring
Returns
- IEnumerable<T>
Type Parameters
T
GetExports(ImportDefinition)
public virtual IEnumerable<Export> GetExports(ImportDefinition importDefinition)
Parameters
importDefinitionImportDefinition
Returns
GetExports(Type, Type, string?)
public IEnumerable<Lazy<object?, object>> GetExports(Type type, Type metadataViewType, string? contractName)
Parameters
Returns
GetExports<T>()
public IEnumerable<Lazy<T>> GetExports<T>()
Returns
- IEnumerable<Lazy<T>>
Type Parameters
T
GetExports<T>(string?)
public IEnumerable<Lazy<T>> GetExports<T>(string? contractName)
Parameters
contractNamestring
Returns
- IEnumerable<Lazy<T>>
Type Parameters
T
GetExports<T, TMetadataView>()
public IEnumerable<Lazy<T, TMetadataView>> GetExports<T, TMetadataView>()
Returns
- IEnumerable<Lazy<T, TMetadataView>>
Type Parameters
TTMetadataView
GetExports<T, TMetadataView>(string?)
public IEnumerable<Lazy<T, TMetadataView>> GetExports<T, TMetadataView>(string? contractName)
Parameters
contractNamestring
Returns
- IEnumerable<Lazy<T, TMetadataView>>
Type Parameters
TTMetadataView
GetMetadataViewDefaults(Type)
Gets a dictionary of metadata that describes all the default values supplied by a metadata view.
protected static IReadOnlyDictionary<string, object?> GetMetadataViewDefaults(Type metadataView)
Parameters
metadataViewTypeThe metadata view type.
Returns
- IReadOnlyDictionary<string, object>
A dictionary of default metadata values.
GetMethodWithArity(Type, string, int)
protected MethodInfo GetMethodWithArity(Type declaringType, string methodName, int arity)
Parameters
Returns
GetStrongTypedMetadata(IReadOnlyDictionary<string, object?>, Type)
protected object GetStrongTypedMetadata(IReadOnlyDictionary<string, object?> metadata, Type metadataType)
Parameters
metadataIReadOnlyDictionary<string, object>metadataTypeType
Returns
GetValueFromMember(object?, MemberInfo, Type?, Type?)
Gets the value from some member of a part.
protected static object? GetValueFromMember(object? exportingPart, MemberInfo exportingMember, Type? importingSiteElementType = null, Type? exportedValueType = null)
Parameters
exportingPartobjectThe instance of the part to extract the value from. May be null for static exports.
exportingMemberMemberInfoThe member exporting the value. May be null for exporting the type/instance itself.
importingSiteElementTypeTypeThe type of the importing member, with ImportMany collections and Lazy/ExportFactory stripped away.
exportedValueTypeTypeThe contractually exported value type.
Returns
- object
The value of the member.
ReleaseExport(Export)
Releases the specified Export from the ExportProvider.
public void ReleaseExport(Export export)
Parameters
exportExportThe export to release.
Remarks
When non-shared parts implement IDisposable they are referenced by this ExportProvider until either the ExportProvider is disposed or the export is released by calling this method.
When provided an Export for a shared part, this method does nothing.
ReleaseExport<T>(Lazy<T>)
Releases the specified Export from the ExportProvider.
public void ReleaseExport<T>(Lazy<T> export)
Parameters
exportLazy<T>The export to release.
Type Parameters
T
Remarks
When non-shared parts implement IDisposable they are referenced by this ExportProvider until either the ExportProvider is disposed or the export is released by calling this method.
When provided an Export for a shared part, this method does nothing.
ReleaseExports(IEnumerable<Export>)
Releases the specified Export instances from the ExportProvider.
public void ReleaseExports(IEnumerable<Export> exports)
Parameters
exportsIEnumerable<Export>The exports to release.
Remarks
When non-shared parts implement IDisposable they are referenced by this ExportProvider until either the ExportProvider is disposed or the export is released by calling this method.
When provided an Export for a shared part, this method does nothing.
ReleaseExports<T>(IEnumerable<Lazy<T>>)
Releases the specified Export instances from the ExportProvider.
public void ReleaseExports<T>(IEnumerable<Lazy<T>> exports)
Parameters
exportsIEnumerable<Lazy<T>>The exports to release.
Type Parameters
T
Remarks
When non-shared parts implement IDisposable they are referenced by this ExportProvider until either the ExportProvider is disposed or the export is released by calling this method.
When provided an Export for a shared part, this method does nothing.
ReleaseExports<T, TMetadataView>(IEnumerable<Lazy<T, TMetadataView>>)
Releases the specified Export instances from the ExportProvider.
public void ReleaseExports<T, TMetadataView>(IEnumerable<Lazy<T, TMetadataView>> exports)
Parameters
exportsIEnumerable<Lazy<T, TMetadataView>>The exports to release.
Type Parameters
TTMetadataView
Remarks
When non-shared parts implement IDisposable they are referenced by this ExportProvider until either the ExportProvider is disposed or the export is released by calling this method.
When provided an Export for a shared part, this method does nothing.
TrackDisposableValue(IDisposable, string?)
Adds a value to be disposed of when this or a parent ExportProvider is disposed of.
protected void TrackDisposableValue(IDisposable instantiatedPart, string? sharingBoundary)
Parameters
instantiatedPartIDisposableThe part to be disposed.
sharingBoundarystringThe sharing boundary associated with the part. May be null for non-shared parts, or the empty string for the default sharing scope.
Remarks
The values are tracked in a set, so calling this repeatedly with the same value is harmless.
TryGetExportingAssemblyName<T>(Lazy<T>, out AssemblyName?)
Gets the assembly that declares a given export.
public static bool TryGetExportingAssemblyName<T>(Lazy<T> export, out AssemblyName? assemblyName)
Parameters
exportLazy<T>The lazy export.
assemblyNameAssemblyNameReceives the name of the assembly that declares the given
export, if known.
Returns
- bool
A value indicating whether
assemblyNamewas set to the declaring assembly.
Type Parameters
TThe type of exported value.