1

这是我不知道正确的 Xml 语法的一个简单问题。在温莎城堡中,我可以复制这行代码:

IoC.Container.AddComponent<IInputRequestedDialog<string>, SealsInputDialog>("seals");

使用此 XML:

<component id="seals" 
    service="MyApp.InputRequestedDialog`1[[System.String]], MyApp" 
    type="MyApp.SealsInputDialog, MyApp" />

但是,如果具体的泛型是字符串数组而不是字符串呢?如何对以下内容进行 xml 化?

IoC.Container.AddComponent<IInputRequestedDialog<string[]>, SealsInputDialog>("seals");
4

1 回答 1

2

引用Castle Project 邮件列表中的 Ken Egozi 的话:


我已经做了

Console.WriteLine(typeof (IFoo<string[]>).FullName); 

输出是:

IFoo`1[[System.String[],mscorlib,版本=2.0.0.0,文化=中性,PublicKeyToken=b77a5c561934e089]]

所以我猜

 service="MyApp.InputRequestedDialog`1[System.String[] ], MyApp" 

应该可以工作,如果没有,

 service="MyApp.InputRequestedDialog`1[[System.String[], mscorlib, Version= 
2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], MyApp" 

System.String[] 效果很好,而且我也学到了一些关于如何找出类型的正确 Xml 表示的知识!

于 2008-10-13T14:54:17.647 回答