I'm fighting with MEF and I stopped at some problem - in my App I have singleton class:
class Config: IConfig {
}
which stores App config data - loaded for example from XML files, DB etc
Now I have some plugins which must have access to the Config - so I wonder what is the best solution to pass the Config to plugin?
My solution for now is:
[ImportMany(typeof (IFieldPlugin))]
public IEnumerable<Lazy<IFieldPlugin, IFieldPluginData>> fieldPlugins;
foreach (var plugin in PluginsStorage.Instance.fieldPlugins)
{
if (plugin.Metadata.Name.Equals(field.Plugin))
{
if(!plugin.IsValueCreated) {
plugin.Value.Config = Config.Instance;
}
result = plugin.Value.DoStep(this,url);
}
}
Any better solution?