【问题标题】:What is standard CLR XML for a concrete generic that is an array?什么是作为数组的具体泛型的标准 CLR XML?
【发布时间】:2010-09-16 14:27:45
【问题描述】:

这是我不知道正确的 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");

【问题讨论】:

    标签: .net xml syntax


    【解决方案1】:

    引用 the Castle Project Mailing list 的 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 表示的知识!

    【讨论】:

    • 支持一个引用我的答案感觉很奇怪:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-06-13
    • 2011-07-09
    • 1970-01-01
    • 1970-01-01
    • 2016-06-10
    • 2019-12-17
    • 2011-09-19
    相关资源
    最近更新 更多