Tell me, can the host transfer some information to it when loading the plug-in or when creating only the default constructor is used?
If not, what are the alternatives?
Tell me, can the host transfer some information to it when loading the plug-in or when creating only the default constructor is used?
If not, what are the alternatives?
You can mark the desired constructor with the ImportingConstructor attribute. Only the container must contain both the argument and the plugin itself.
For example:
[Export(typeof(ILogger))] class Logger : ILogger {} [Export(typeof(IPlugin))] class Plugin : IPlugin { [ImportingConstructor] public Plugin(ILogger logger) { } } Catalog:
var catalog = new TypeCatalog(typeof(Plugin), typeof(Logger)); Source: https://ru.stackoverflow.com/questions/618180/
All Articles