It appears that the MEF structure creates objects that have CTORs by default. How about a custom CTOR or Constructor with options? For example:
[Export (typeof(IInterface1))]
public class MyClass : IInterface1
{
public MyClass(int id) {....}
....
}
If not, one way I can think of is to pass the object as CTOR parameters. For example:
public Interface IParameterID {public int Id {get; private recruitment; } ...}
Then CTOR will be:
public MyClass([Import(typeof(IParameter))] IParameterID id)
{ ... }
Not sure if you can add an attribute to CTOR parameters? And the next question: if MEF will automatically create an instance of IParameter and add it to the CTOR parameter?
source
share