AssemblyCatalog AssemblyCatalog AssemblyCatalog AssemblyCatalog Class

Definition

Discovers attributed parts in a managed code assembly.

public ref class AssemblyCatalog : System::ComponentModel::Composition::Primitives::ComposablePartCatalog, System::ComponentModel::Composition::Primitives::ICompositionElement
public class AssemblyCatalog : System.ComponentModel.Composition.Primitives.ComposablePartCatalog, System.ComponentModel.Composition.Primitives.ICompositionElement
type AssemblyCatalog = class
    inherit ComposablePartCatalog
    interface ICompositionElement
Public Class AssemblyCatalog
Inherits ComposablePartCatalog
Implements ICompositionElement
Inheritance
Implements

Examples

The following code demonstrates the common scenario of an application creating an AssemblyCatalog to parse its own assembly. This is a straightforward way to load parts contained in a single project into the Managed Extensibility Framework (MEF).

[Export]
class MyAddin
{
    public String myData { get { return "The data!"; } }
}

class MyProgram
{
    [Import]
    public MyAddin myAddin { get; set; }
}


class Program
{
    static void Main(string[] args)
    {
        AggregateCatalog catalog = new AggregateCatalog();
        catalog.Catalogs.Add(new AssemblyCatalog(typeof(MyAddin).Assembly));
        CompositionContainer _container = new CompositionContainer(catalog);
        MyProgram myProgram = new MyProgram();
        _container.SatisfyImportsOnce(myProgram);
        Console.WriteLine(myProgram.myAddin.myData);
        Console.ReadLine();

        _container.Dispose();
    }
}
<Export()>
Public Class MyAddin
    Public ReadOnly Property theData As String
        Get
            Return "The Data!"
        End Get
    End Property
End Class

Public Class MyProgam
    Private _MyAddin As MyAddin

    <Import()>
    Public Property MyAddinProperty As MyAddin
        Get
            Return _MyAddin
        End Get
        Set(ByVal value As MyAddin)
            _MyAddin = value
        End Set
    End Property

End Class



Sub Main()
    Dim catalog As AggregateCatalog = New AggregateCatalog()
    catalog.Catalogs.Add(New AssemblyCatalog(GetType(MyAddin).Assembly))
    Dim container As CompositionContainer = New CompositionContainer(catalog)
    Dim theProgam As MyProgam = New MyProgam()
    container.SatisfyImportsOnce(theProgam)
    Console.WriteLine(theProgam.MyAddinProperty.theData)
    Console.ReadLine()

    container.Dispose()

End Sub

Remarks

An AssemblyCatalog is used to parse all the parts present in a specified assembly. The target assembly can be indicated either by object reference or by path.

Important

This type implements the IDisposable interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its Dispose method in a try/catch block. To dispose of it indirectly, use a language construct such as using (in C#) or Using (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the IDisposable interface topic.

This type is thread safe.

Constructors

AssemblyCatalog(Assembly) AssemblyCatalog(Assembly) AssemblyCatalog(Assembly) AssemblyCatalog(Assembly)

Initializes a new instance of the AssemblyCatalog class with the specified assembly.

AssemblyCatalog(Assembly, ICompositionElement) AssemblyCatalog(Assembly, ICompositionElement) AssemblyCatalog(Assembly, ICompositionElement) AssemblyCatalog(Assembly, ICompositionElement)

Initializes a new instance of the AssemblyCatalog class with the specified assembly.

AssemblyCatalog(Assembly, ReflectionContext) AssemblyCatalog(Assembly, ReflectionContext) AssemblyCatalog(Assembly, ReflectionContext) AssemblyCatalog(Assembly, ReflectionContext)

Initializes a new instance of the AssemblyCatalog class with the specified assembly and reflection context.

AssemblyCatalog(Assembly, ReflectionContext, ICompositionElement) AssemblyCatalog(Assembly, ReflectionContext, ICompositionElement) AssemblyCatalog(Assembly, ReflectionContext, ICompositionElement) AssemblyCatalog(Assembly, ReflectionContext, ICompositionElement)

Initializes a new instance of the AssemblyCatalog class with the specified assembly and reflection context.

AssemblyCatalog(String) AssemblyCatalog(String) AssemblyCatalog(String) AssemblyCatalog(String)

Initializes a new instance of the AssemblyCatalog class with the specified code base.

AssemblyCatalog(String, ICompositionElement) AssemblyCatalog(String, ICompositionElement) AssemblyCatalog(String, ICompositionElement) AssemblyCatalog(String, ICompositionElement)

Initializes a new instance of the AssemblyCatalog class with the specified code base.

AssemblyCatalog(String, ReflectionContext) AssemblyCatalog(String, ReflectionContext) AssemblyCatalog(String, ReflectionContext) AssemblyCatalog(String, ReflectionContext)

Initializes a new instance of the AssemblyCatalog class with the specified code base and reflection context.

AssemblyCatalog(String, ReflectionContext, ICompositionElement) AssemblyCatalog(String, ReflectionContext, ICompositionElement) AssemblyCatalog(String, ReflectionContext, ICompositionElement) AssemblyCatalog(String, ReflectionContext, ICompositionElement)

Initializes a new instance of the AssemblyCatalog class with the specified code base and reflection context.

Properties

Assembly Assembly Assembly Assembly

Gets the assembly whose attributed types are contained in the assembly catalog.

Parts Parts Parts Parts

Gets the part definitions that are contained in the assembly catalog.

Methods

Dispose() Dispose() Dispose() Dispose()

Releases all resources used by the ComposablePartCatalog.

(Inherited from ComposablePartCatalog)
Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

Releases the unmanaged resources used by the AssemblyCatalog and optionally releases the managed resources.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

Returns an enumerator that iterates through the catalog.

GetExports(ImportDefinition) GetExports(ImportDefinition) GetExports(ImportDefinition) GetExports(ImportDefinition)

Gets a collection of exports that match the conditions specified by the import definition.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Gets a string representation of the assembly catalog.

Explicit Interface Implementations

ICompositionElement.DisplayName ICompositionElement.DisplayName ICompositionElement.DisplayName ICompositionElement.DisplayName

Gets the display name of the AssemblyCatalog object.

ICompositionElement.Origin ICompositionElement.Origin ICompositionElement.Origin ICompositionElement.Origin

Gets the composition element that this element originated from.

IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator()

Returns an enumerator that iterates through the catalog.

(Inherited from ComposablePartCatalog)

Extension Methods

CreateCompositionService(ComposablePartCatalog) CreateCompositionService(ComposablePartCatalog) CreateCompositionService(ComposablePartCatalog) CreateCompositionService(ComposablePartCatalog)

Creates a new composition service by using the specified catalog as a source for exports.

Filter(ComposablePartCatalog, Func<ComposablePartDefinition,Boolean>) Filter(ComposablePartCatalog, Func<ComposablePartDefinition,Boolean>) Filter(ComposablePartCatalog, Func<ComposablePartDefinition,Boolean>) Filter(ComposablePartCatalog, Func<ComposablePartDefinition,Boolean>)

Filters the specified catalog with the specified filter function.

CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>)

Returns a DataTable that contains copies of the DataRow objects, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption)

Copies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler)

Copies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

Enables parallelization of a query.

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

Converts an IEnumerable to an IQueryable.

Ancestors<T>(IEnumerable<T>) Ancestors<T>(IEnumerable<T>) Ancestors<T>(IEnumerable<T>) Ancestors<T>(IEnumerable<T>)

Returns a collection of elements that contains the ancestors of every node in the source collection.

Ancestors<T>(IEnumerable<T>, XName) Ancestors<T>(IEnumerable<T>, XName) Ancestors<T>(IEnumerable<T>, XName) Ancestors<T>(IEnumerable<T>, XName)

Returns a filtered collection of elements that contains the ancestors of every node in the source collection. Only elements that have a matching XName are included in the collection.

DescendantNodes<T>(IEnumerable<T>) DescendantNodes<T>(IEnumerable<T>) DescendantNodes<T>(IEnumerable<T>) DescendantNodes<T>(IEnumerable<T>)

Returns a collection of the descendant nodes of every document and element in the source collection.

Descendants<T>(IEnumerable<T>) Descendants<T>(IEnumerable<T>) Descendants<T>(IEnumerable<T>) Descendants<T>(IEnumerable<T>)

Returns a collection of elements that contains the descendant elements of every element and document in the source collection.

Descendants<T>(IEnumerable<T>, XName) Descendants<T>(IEnumerable<T>, XName) Descendants<T>(IEnumerable<T>, XName) Descendants<T>(IEnumerable<T>, XName)

Returns a filtered collection of elements that contains the descendant elements of every element and document in the source collection. Only elements that have a matching XName are included in the collection.

Elements<T>(IEnumerable<T>) Elements<T>(IEnumerable<T>) Elements<T>(IEnumerable<T>) Elements<T>(IEnumerable<T>)

Returns a collection of the child elements of every element and document in the source collection.

Elements<T>(IEnumerable<T>, XName) Elements<T>(IEnumerable<T>, XName) Elements<T>(IEnumerable<T>, XName) Elements<T>(IEnumerable<T>, XName)

Returns a filtered collection of the child elements of every element and document in the source collection. Only elements that have a matching XName are included in the collection.

InDocumentOrder<T>(IEnumerable<T>) InDocumentOrder<T>(IEnumerable<T>) InDocumentOrder<T>(IEnumerable<T>) InDocumentOrder<T>(IEnumerable<T>)

Returns a collection of nodes that contains all nodes in the source collection, sorted in document order.

Nodes<T>(IEnumerable<T>) Nodes<T>(IEnumerable<T>) Nodes<T>(IEnumerable<T>) Nodes<T>(IEnumerable<T>)

Returns a collection of the child nodes of every document and element in the source collection.

Remove<T>(IEnumerable<T>) Remove<T>(IEnumerable<T>) Remove<T>(IEnumerable<T>) Remove<T>(IEnumerable<T>)

Removes every node in the source collection from its parent node.

Applies to