繁体   English   中英

CompositionContainer:如何从导出的值中获取源类

[英]CompositionContainer: How can I get the source class from an exported value

如果我有以下出口

Class A 
    [Export(typeof(IFOOExport))]
    public   IFOOExport ExportedFunctions_FULL = new FunctionsExport
    {
        Sub = String.Empty;

    };

Class B
   [Export(typeof(IFOOExport))]
    public   IFOOExport ExportedFunctions_EMPTY = new FunctionsExport
    {
        Sub = String.Empty;

    };

然后我得到列表:

 var exp_list=   CompositionContainer.GetExportedValues<IFOOExport>();

我应该在列表中有两个元素,而我的问题是:

如何确定从ExportedFunctions_EMPTY导出的是哪一个?

您可以简单地调用GetType()方法并检查返回的Type对象的FullName属性。

foreach (var exp in exp_list)
{
    Console.WriteLine(exp.GetType().FullName);
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM