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

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條評論
主站蜘蛛池模板: 中文字幕 日韩有码 | 四虎影院新网址 | 国产色产综合色产在线观看视频 | 久久中文字幕网 | 久久久久亚洲国产 | 国产精品综合一区二区三区 | 国产欧美久久一区二区 | 久久亚洲精品中文字幕三区 | 午夜免费一级片 | 中国护士一级毛片免费版本 | 在线亚洲激情 | 岛国精品在线观看 | 亚洲欧美日韩高清在线看 | 久久激情综合网 | www色中色| 玖玖精品视频 | 日韩欧美黄色片 | 免费一级特黄 | 手机看片福利视频 | 精品日韩一区二区三区 | 国内精品区一区二区三 | 老司机精品在线观看 | 久久亚洲日本不卡一区二区 | 中文成人在线 | 国产精品视频偷伦精品视频 | 久久99精品一久久久久久 | www.日日| 久久久久久尹人网香蕉 | 久久亚洲精品视频 | 欧美一区永久视频免费观看 | 国产专区在线播放 | 九九久久国产精品免费热6 九九久久精品 | 日本一级做人免费视频 | 亚洲日本在线播放 | 在线免费国产视频 | 久久久男女野外野战 | 亚洲三级在线免费观看 | 黄色日比视频 | 国产欧美另类 | 久久国产精品自由自在 | 亚洲国产日产韩国欧美综合 |