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
importingSiteElementType
TypesharingBoundaries
IReadOnlyCollection<string>valueFactory
Func<KeyValuePair<object, IDisposable>>exportFactoryType
TypeexportMetadata
IReadOnlyDictionary<string, object>
Returns
Dispose()
public void Dispose()
Dispose(bool)
protected virtual void Dispose(bool disposing)
Parameters
disposing
bool
GetExport<T>()
public Lazy<T> GetExport<T>()
Returns
- Lazy<T>
Type Parameters
T
GetExport<T>(string?)
public Lazy<T> GetExport<T>(string? contractName)
Parameters
contractName
string
Returns
- Lazy<T>
Type Parameters
T
GetExport<T, TMetadataView>()
public Lazy<T, TMetadataView> GetExport<T, TMetadataView>()
Returns
- Lazy<T, TMetadataView>
Type Parameters
T
TMetadataView
GetExport<T, TMetadataView>(string?)
public Lazy<T, TMetadataView> GetExport<T, TMetadataView>(string? contractName)
Parameters
contractName
string
Returns
- Lazy<T, TMetadataView>
Type Parameters
T
TMetadataView
GetExportedValue<T>()
public T GetExportedValue<T>()
Returns
- T
Type Parameters
T
GetExportedValue<T>(string?)
public T GetExportedValue<T>(string? contractName)
Parameters
contractName
string
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
contractName
string
Returns
- IEnumerable<T>
Type Parameters
T
GetExports(ImportDefinition)
public virtual IEnumerable<Export> GetExports(ImportDefinition importDefinition)
Parameters
importDefinition
ImportDefinition
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
contractName
string
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
T
TMetadataView
GetExports<T, TMetadataView>(string?)
public IEnumerable<Lazy<T, TMetadataView>> GetExports<T, TMetadataView>(string? contractName)
Parameters
contractName
string
Returns
- IEnumerable<Lazy<T, TMetadataView>>
Type Parameters
T
TMetadataView
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
metadataView
TypeThe 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
metadata
IReadOnlyDictionary<string, object>metadataType
Type
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
exportingPart
objectThe instance of the part to extract the value from. May be null for static exports.
exportingMember
MemberInfoThe member exporting the value. May be null for exporting the type/instance itself.
importingSiteElementType
TypeThe type of the importing member, with ImportMany collections and Lazy/ExportFactory stripped away.
exportedValueType
TypeThe 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
export
ExportThe 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
export
Lazy<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
exports
IEnumerable<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
exports
IEnumerable<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
exports
IEnumerable<Lazy<T, TMetadataView>>The exports to release.
Type Parameters
T
TMetadataView
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
instantiatedPart
IDisposableThe part to be disposed.
sharingBoundary
stringThe 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
export
Lazy<T>The lazy export.
assemblyName
AssemblyNameReceives the name of the assembly that declares the given
export
, if known.
Returns
- bool
A value indicating whether
assemblyName
was set to the declaring assembly.
Type Parameters
T
The type of exported value.