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

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條評論
主站蜘蛛池模板: 国产第一福利影院 | 亚洲五月综合缴情婷婷 | 毛片网站免费观看 | 日日插日日操 | 国产亚洲自在精品久久 | 久草综合视频 | 国产精品久久久久一区二区三区 | 亚洲二三区 | 亚洲精品色播一区二区 | 久久久久综合精品福利啪啪 | 天天插天天操天天射 | 欧美午夜视频一区二区三区 | 欧美黑大粗硬毛片视频 | 狠狠色噜噜狠狠狠狠奇米777 | 久久riav国产精品 | 亚洲高清视频一区 | 毛片在线视频观看 | 久久精品视频播放 | 九九精品热 | 免费网站啪啪大全 | 狠狠色丁香婷婷久久综合考虑 | 福利一区在线视频 | 精品日韩 | 国产一区二区三区不卡在线观看 | 久久伊人一区二区三区四区 | 免费一级特黄 欧美大片 | 成人免费观看www视频 | 久久经典免费视频 | 国产三及 | 欧美高清在线精品一区二区不卡 | 国产精品亚洲专一区二区三区 | 99热7| 久久精品国产99久久99久久久 | 久久久精品久久久久久 | 每日更新国产精品视频 | 全部免费毛片在线 | 久久99亚洲精品久久久久 | 色综合视频一区二区三区 | 国语精品91自产拍在线观看二区 | 乱子伦有声小说mp3 仑乱高清在线一级播放 | 永久黄网站色视频免费观看99 |