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

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條評論
主站蜘蛛池模板: 亚洲区欧美区 | 久久精品视频亚洲 | 九九色综合 | 色一情一乱一乱91av | 日韩高清性爽一级毛片免费 | 久久中文网中文字幕 | 天天干天天操天天玩 | 伊人伊色| 精品国产线拍大陆久久尤物 | 精品特级一级毛片免费观看 | 你懂的91 | 爱色aⅴ| 看片福利| 亚洲福利一区福利三区 | 日韩亚洲一区中文字幕 | 操操操日日日 | 日韩视频 中文字幕 视频一区 | 国产一级α片 | www成人免费视频 | 国产成人一区二区三区 | 日韩一区二区三区中文字幕 | 2019年国产高清情侣视频 | 欧美在线一级毛片视频 | 天天插天天射天天操 | 不卡网 | 欧美日韩顶级毛片www免费看 | 久久久精品免费 | 成人在线午夜 | 色婷婷在线视频 | 在线视频精品一区 | 亚洲精品乱码久久久久蜜桃 | 天天躁狠狠躁 | 亚洲狠狠婷婷综合久久久久图片 | 狠狠色综合色综合网络 | 久草.com| 日韩一及片 | 久久激情影院 | 精品视频亚洲 | 丝袜三级 | 国产日韩亚洲欧洲一区二区三区 | 操亚洲美女 |