tôi là chuyển đổi một ứng dụng Castle/đường ray thành một Unity/Asp.NET MVC một, Tôi đang mắc kẹt trong cố gắng để chuyển đổi cấu hình thành phần này:Unity: Xây dựng một từ điển
<component
id="ComponentBaseConfiguration"
service="MyFakeNamespace.BOL.IConfiguration, MyFakeAppDll"
type="MyFakeNamespace.BOL.ConfigurableConfiguration, MyFakeAppDll">
<parameters>
<!-- Setting Configuration (Dictionary<string,string>)-->
<Config>
<dictionary>
<entry key="localHost">#{LocalHost}</entry>
<entry key="contentHost">#{ContentHost}</entry>
<entry key="virtualDir">#{VirtualDir}</entry>
</dictionary>
</Config>
</parameters>
vẻ như Unity hỗ trợ mảng nhưng không điển, tôi muốn làm một cái gì đó như thế này:
<unity>
<containers>
<container>
<types>
<type name="ComponentBaseConfiguration" type="MyFakeNamespace.BOL.IConfiguration, MyFakeAppDll" mapTo="MyFakeNamespace.BOL.ConfigurableConfiguration, MyFakeAppDll">
<typeConfig extensionType="Microsoft.Practices.Unity.Configuration.TypeInjectionElement, Microsoft.Practices.Unity.Configuration">
<property name="Config" propertyType="System.Collections.Generic.Dictionary`2[[System.String, mscorlib], [System.String, mscorlib]],mscorlib">
<dictionary>
<entry key="localHost">127.0.0.1</keyedValue>
<entry key="contentHost">\\content</keyedValue>
<entry key="virtualDir">/</keyedValue>
</dictionary>
</property>
</typeConfig>
</type>
</types>
</container>
</containers></unity>
làm thế nào tôi có thể đạt được một cái gì đó như thế này?
Tôi nhận được thông báo như thế này để hoạt động. xem - http://stackoverflow.com/questions/5597492/how-do-i-create-and-populate-a-dictionarystring-object-using-unitys-xml-confi/7901103#7901103 – ScArcher2
Đây là giải pháp của tôi cho cũ hơn phiên bản - nó đòi hỏi một số thay đổi trong mã - khi tôi sẽ có thời gian có lẽ tôi sẽ cố gắng để thích ứng với vesion mới của Unity http://unity.codeplex.com/discussions/230927/ – AdaskoTheBeAsT