I would like to dynamically apply the MEF export attribute to the type at runtime, just as if the type had the Export attribute applied at compile time.
Is there an easy way to do this?
Prohibition of whether there is a difficult way to do this?
If you can allow the use of .NET 4.5 (which means giving up support for Windows XP), now you can use MEF without regard to the attribute aka Model convention .
MEF .NET4 , MEF , ExportProvider ComposablePartCatalog.
MEF Contrib Fluent Definition Provider - , .
MEF Contrib r, XML.
- Autofac, MEF, MEF.
100%, , MEF. , , factory/provider.
interface IData {} interface IDataProvider { IData Data { get; set; } } [Export(IDataProvider)] class DataProvider : IDataProvider { public IData { get; set; } }
IData , .
IData