[英]CompositionContainer: How can I get the source class from an exported value
if I have following exports 如果我有以下出口
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;
};
then I get the list: 然后我得到列表:
var exp_list= CompositionContainer.GetExportedValues<IFOOExport>();
I should have two elements in the list, and my question is: 我应该在列表中有两个元素,而我的问题是:
How can I identify which one is export from ExportedFunctions_EMPTY which one come from ExportedFunctions_FULL? 如何确定从ExportedFunctions_EMPTY导出的是哪一个?
You can simply call the GetType()
method and inspect the FullName
property of the returned Type
object. 您可以简单地调用
GetType()
方法并检查返回的Type
对象的FullName
属性。
foreach (var exp in exp_list)
{
Console.WriteLine(exp.GetType().FullName);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.