Table of Contents

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

ImmutableDictionary<string, object>

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

Lazy<object>

Properties

NonDisposableWrapper

Gets a lazy that creates an instance of DelegatingExportProvider.

protected Lazy<object> NonDisposableWrapper { get; }

Property Value

Lazy<object>

NonDisposableWrapperExportAsListOfOne

protected ImmutableList<Export> NonDisposableWrapperExportAsListOfOne { get; }

Property Value

ImmutableList<Export>

Resolver

protected Resolver Resolver { get; }

Property Value

Resolver

Methods

CannotInstantiatePartWithNoImportingConstructor()

protected static object CannotInstantiatePartWithNoImportingConstructor()

Returns

object

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 Type
sharingBoundaries IReadOnlyCollection<string>
valueFactory Func<KeyValuePair<object, IDisposable>>
exportFactoryType Type
exportMetadata IReadOnlyDictionary<string, object>

Returns

object

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

type Type
contractName string

Returns

IEnumerable<object>

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

IEnumerable<Export>

GetExports(Type, Type, string?)

public IEnumerable<Lazy<object?, object>> GetExports(Type type, Type metadataViewType, string? contractName)

Parameters

type Type
metadataViewType Type
contractName string

Returns

IEnumerable<Lazy<object, object>>

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 Type

The 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

declaringType Type
methodName string
arity int

Returns

MethodInfo

GetStrongTypedMetadata(IReadOnlyDictionary<string, object?>, Type)

protected object GetStrongTypedMetadata(IReadOnlyDictionary<string, object?> metadata, Type metadataType)

Parameters

metadata IReadOnlyDictionary<string, object>
metadataType Type

Returns

object

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 object

The instance of the part to extract the value from. May be null for static exports.

exportingMember MemberInfo

The member exporting the value. May be null for exporting the type/instance itself.

importingSiteElementType Type

The type of the importing member, with ImportMany collections and Lazy/ExportFactory stripped away.

exportedValueType Type

The 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 Export

The 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 IDisposable

The part to be disposed.

sharingBoundary string

The 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 AssemblyName

Receives 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.