Definition Providers

Where the model that is included with MEF only enables developers to declare imports and exports using an attributed approach, the provider model introduces a concept known as definition providers.

A definition provider exists on top of the definition provider abstraction layer and enables developers to easily introduce new ways of declaring definitions. To close the gap between how definitions are declared and how the provider model can be aware of them you inherit the abstract base class DefinitionProvider.

public abstract class DefinitionProvider
{
    public abstract IEnumerable<PartDescription> Parts { get; }
}

It only contains one member, a collection of PartDescription objects, one of the data transfer objects in the definition provider abstraction layer, which in turn contains collection so ImportDescription and ExportDescription objects.

The DefinitionProvider is then passed to the DefinitionProviderPartCatalog which queries the definition provider about the PartDescription objects it’s aware of and translates them into a format that MEF understands.

There are currently three providers shipped with Preview 1 and those are

Description Link
Attributed Definition Provider Attributed
Configurable Definition Provider Configurable
Fluent Definition Provider Fluent

Last edited Mar 1, 2009 at 1:10 PM by TheCodeJunkie, version 1

Comments

No comments yet.