IOCFactory 2013.10.24版本發佈說明

更新說明:
1、更正之前的unity的mapping xml格式以及讀取方式
2、增加讀取寫在.config文件中的unity格式的section來進行註冊的方式
3、增加了.config文件的section handler.

具體例子表現爲:
setting.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?xml version="1.0" encoding="utf-8" ?>
<unity>
<typeAliases>
<typeAlias alias="Interface" type="IOCFactoryUnitTest.Animal,IOCFactoryUnitTest"/>
<typeAlias alias="Object" type="IOCFactoryUnitTest.Dog,IOCFactoryUnitTest"/>
</typeAliases>
<containers>
<container name="containerOne">
<types>
<type type="Interface" mapTo="Object">
<lifetime type="singleton"/>
</type>
</types>
</container>
</containers>
</unity>

.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="unity" type="IOCFactory.Util.IOCFactoryUnitySectionHandler,IOCFactory"/>
</configSections>
<unity configSource="setting.xml" />
</configuration>

註冊調用

1
factory.RegistFromSection("unity");

點擊 訪問github獲取本項目的最新代碼

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章