MEF dafault导入基类

时间:2016-01-26 17:17:23

标签: c# mef

我有一个员工对象:

public class CreateEmployee 
{
    public string FirstName { get; set; }
    public string LastName { get; set; }

    [Import(AllowDefault=true)]
    public ExtendEmployee ExtendEmployee { get; set; }
}

public class ExtendEmployee
{
    public string Id { get; set; }
}

我想在运行时使用MEF扩展此ExtendEmployee。

[Export]
public class ExtendCreateEmployee : ExtendEmployee
{
    public decimal Salary { get; set; }
}
  

我的问题是:如果我没有定义这个[导出],有没有办法   导入基类" ExtendEmployee"而不是默认的null   进口。

我考虑过使用[Export]属性来装饰基类,但在这种情况下,导入将考虑这两个类,我必须过滤继承的类。如果有办法从基类或继承类中进行选择,这可能没问题。

由于

0 个答案:

没有答案
相关问题