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

EntLib 4.1 第一章 Configuration-Migration(

系統 1811 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條評論
主站蜘蛛池模板: 99久久精品免费看国产麻豆 | 9999热视频 | 爱爱视频网站免费 | 国产91一区二这在线播放 | 奇米影视888狠狠狠777九色 | 亚洲国产成人九九综合 | 爱爱视频天天看 | 热re99久久精品国产99热 | 日韩 欧美 中文字幕 不卡 | 九九视频免费观看 | 久久国产网 | 亚洲精品国产经典一区二区 | 亚洲国产人成在线观看69网站 | a一级毛片视频免费看 | 久热爱免费精品视频在线播放 | 欧美亚洲日本在线 | 亚洲综合久 | 欧美成人午夜视频在线观看 | 国产精品欧美在线观看 | 国产高清免费视频 | 精品在线视频观看 | 亚洲精品成人 | 久久99一区| 大伊香蕉精品视频在线天堂 | 色柚视频 | 91精品国产综合久久精品 | 亚洲精品专区一区二区三区 | 日日插夜夜操 | 99久久免费观看 | 操熟美女又肥又嫩的骚屁股 | 久久99国产乱子伦精品免费 | 亚洲破处视频 | 一级午夜| 日本毛片在线看 | 美日韩毛片 | 欧美激情在线播放一区二区 | 亚洲第一伊人 | 香蕉黄视频 | 久久久精品视频免费观看 | 天天鲁天天爱天天鲁天天 | 奇米网在线观看 |