【问题标题】:Is it possible to configure embbeded Dictionaries using C#.NET4.0 and Windsor Castle是否可以使用 C#.NET4.0 和 Windsor Castle 配置嵌入式词典
【发布时间】:2011-12-08 19:06:11
【问题描述】:

在 C#.NET4.0 和 Windsor castle IoC Framework v2.5.3 中, 是否可以配置嵌入字典?

我尝试了一些配置(见下文)但没有成功。

这里是 Components.xml 文件

<component
   id="MyComponent"
   service="MyAssembly.IMyInterface,MyAssembly"
   type="MyAssembly.MyClass,MyAssembly">
  <parameters>
    <MyProperty>#{MyComplexDictionaryProperty}</MyProperty>
  </parameters>
</component>

这里是 ComponentsProperties.xml 文件:

<MyComplexDictionaryProperty>
  <Dictionary
    keyType="MyAssembly.MyEnum1,MyAssembly"
    valueType="... ??? ...">
    <Entry key="MyEnum1Value1">
      <Dictionary
        keyType="MyAssembly.MyEnum2,MyAssembly"
        valueType="System.Int32, mscorlib">
        <Entry key="MyEnum2Value1">1</Entry>
      </Dictionary>
    </Entry>
  </Dictionary>
</MyComplexDictionaryProperty>

谢谢:-)

【问题讨论】:

  • 我认为如果你有字典,温莎的配置是你最少的问题。在我看来你在滥用原语

标签: c# .net-4.0 dictionary castle-windsor ioc-container


【解决方案1】:

我以前从未见过这样做过。根据documentation on XML configuration,井号(#)语法用于引用配置文件中的另一个属性,格式为“property.id”。你确定你使用正确吗?

【讨论】:

    猜你喜欢
    • 2012-01-21
    • 2011-06-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-17
    相关资源
    最近更新 更多