亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

EntLib 4.1 第一章 Configuration-Migration(

系統 1576 0
一開始沒接觸過的先看看TerryLee的文章吧:
Enterprise Library Step By Step 系列(一):配置應用程序塊—— 入門篇
Enterprise Library Step By Step 系列(二):配置應用程序塊—— 進階篇

以下講解4.1與2.0的不同
首先我們來看自定義數據類
?1 using ?System.Text;
?2 using ?System.Configuration;
?3
?4 namespace ?ConfigurationMigrationQuickStart
?5 {
?6 ???? /// ? <summary>
?7 ???? /// ?Summary?description?for?ConfigurationData.
?8 ???? /// ? </summary>

?9 ???? public ? class ?EditorFontData?:?ConfigurationSection?
10 ???? {????????
11
12 ???????? public ?EditorFontData()
13 ???????? {??????????
14 ????????}

15
16 ????????[ConfigurationProperty( " name " )]
17 ???????? public ? string ?Name?
18 ???????? {
19 ???????????? get ? {? return ?( string ) this [ " name " ];?}
20 ???????????? set {? this [ " name " ]? = ?value;?}
21 ????????}

22
23 ????????[ConfigurationProperty( " size " )]
24 ???????? public ? float ?Size?
25 ???????? {
26 ???????????? get {? return ?( float ) this [ " size " ];?}
27 ???????????? set {? this [ " size " ]? = ?value;?}
28 ????????}

29
30 ????????[ConfigurationProperty( " style " )]
31 ???????? public ? int ?Style?
32 ???????? {
33 ???????????? get ? {? return ?( int ) this [ " style " ];?}
34 ???????????? set {? this [ " style " ]? = ?value;?}
35 ????????}
?
36
37 ???????? public ? override ? string ?ToString()?
38 ???????? {
39 ????????????StringBuilder?sb? = ? new ?StringBuilder();
40 ????????????sb.AppendFormat( " Name?=?{0};?Size?=?{1};?Style?=?{2} " ,?Name,?Size.ToString(),?Style.ToString());
41
42 ???????????? return ?sb.ToString();
43 ????????}

44 ????}

45 }

46

?

用屬性(Attribution)來標記了對應的屬性(Property)
如[ConfigurationProperty( " name " )]
下面結合App.config來看

App.config


可見,每個屬性(Attribute)都對應著XML節點的屬性


與2.0不同的是,4.1中好像沒法用用Enterprise Library Configuration配置應用程序
以下是配置的詳細步驟:
先建立一個項目,
然后建立自定義配置數據類,
在App.config或Web.config中添加節點<configSections>
在<configSections>節點下添加你自定義的節點的信息如:

?? < configSections >
????
< section? name ="EditorSettings" ?type ="ConsoleApplication1.EditorFontData,?ConsoleApplication1,?Version=1.1.0.0,?Culture=neutral,?PublicKeyToken=null" ? />
??
</ configSections >

然后添加你自定義的節點
在工程中添加引用System.Configureation,如圖所示:
Ref.JPG

讀的代碼:
EditorFontData?configData? = ?ConfigurationManager.GetSection( " EditorSettings " )? as ?EditorFontData;

寫的代碼:
// ?Write?the?new?configuration?data?to?the?XML?file
Configuration?config? = ?ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.Sections.Remove(
" EditorSettings " );
config.Sections.Add(
" EditorSettings " ,?configData);
config.Save();

清除緩存的代碼:
ConfigurationManager.RefreshSection( " EditorSettings " );

EntLib 4.1 第一章 Configuration-Migration(配置應用程序塊)


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 五月综合激情视频在线观看 | 亚洲视频在线a视频 | 久久香蕉国产线看精品 | 成人精品网| 伦理亚洲 | 亚洲欧洲久久 | 久久精品视频3 | 日本一级淫一片免费 | 精品日本亚洲一区二区三区 | 国产亚洲精品激情都市 | 不卡不卡| 久久青草免费91线频观看站街 | 99精品在线播放 | 久久精品国产亚洲香蕉 | 一区二区三区在线播放 | 精品国产一区二区三区www | 四虎精品在线观看 | 5060网永久免费一级毛片 | 五月天婷婷免费视频观看 | 亚洲国产成人精品91久久久 | 精品精品国产欧美在线观看 | 久久久四虎成人永久免费网站 | 在线亚洲欧美日韩 | 澳门四虎影院 | 香蕉久久ac一区二区三区 | 国产精品激情综合久久 | 亚欧洲精品在线视频免费观看 | 日本欧美精品 | 亚洲国产一区二区在线 | 自拍 欧美 在线 综合 另类 | 日韩三级不卡 | 国外免费一级 | 国产精品亚洲综合一区 | 国产成人香蕉在线视频网站 | 99热国产这里只有精品免费 | 国产一区二区三区在线观看精品 | 色婷婷久久综合中文网站 | 一级大片视频 | 天堂一区二区在线观看 | 国产视频一区二区 | 亚洲国产视频在线 |