人人做人人澡人人爽欧美,国产主播一区二区,久久久精品五月天,羞羞视频在线观看免费

當前位置:蘿卜系統下載站 > 技術開發教程 > 詳細頁面

取得設置文件中configSections的設置信息!

取得設置文件中configSections的設置信息!

更新時間:2022-10-08 文章作者:未知 信息來源:網絡 閱讀次數:

configSections的作用很多!我就不多舉了。

首先要注意的一點是!configSections關聯的類型在一個進程內只實例化一次,

1、配置文件Web.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="xinyulou" type="Config.ConfigurationHandler, Config" />
</configSections>

<xinyulou>
<add name="Region" value = "心雨樓" />
</xinyulou>


<system.web>
<compilation defaultLanguage="c#" debug="true" />
<customErrors mode="RemoteOnly" />
<authentication mode="Windows" />
<authorization>
<allow users="*" /> <!-- <sectionGroup name="xinyulou"> 允許所有用戶 -->
</authorization>
<trace enabled="false" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true" />
<sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
cookieless="false" timeout="20" />
<globalization requestEncoding="utf-8" responseEncoding="utf-8" />
</system.web>

</configuration>

2、兩個重要的類

using System;
using System.Configuration;
using System.Collections;
using System.Xml;

namespace Config
{
public class Configuration
{
private Hashtable m_MyRegionConfig = new Hashtable();
public Hashtable MyRegionConfig
{
get {return m_MyRegionConfig;}

}
public static Configuration GetConfig()
{
return (Configuration) ConfigurationSettings.GetConfig("xinyulou");
}
internal void LoadValuesFromConfigurationXml(XmlNode node)
{

foreach (XmlNode child in node.ChildNodes)
{
m_MyRegionConfig.Add(child.Attributes["name"].Value,child.Attributes["value"].Value);
}

}

}

internal class ConfigurationHandler : IConfigurationSectionHandler
{

public virtual object Create(Object parent, Object context, XmlNode node)
{
Configuration config = new Configuration();
config.LoadValuesFromConfigurationXml(node);
return config;
}

}
}

3、示例在aspx中用!

private void Page_Load(object sender, System.EventArgs e)
{
Response.Write(Configuration.GetConfig().MyRegionConfig["Region"].ToString());
}



configSections的威力很強大。有很多種用法與應用!這里就不再舉例了,有問題可與我聯系。或在恢復中提出來!

溫馨提示:喜歡本站的話,請收藏一下本站!

本類教程下載

系統下載排行

網站地圖xml | 網站地圖html
主站蜘蛛池模板: 金坛市| 松原市| 阳高县| 青州市| 永靖县| 青冈县| 三门县| 册亨县| 贡嘎县| 宣恩县| 武穴市| 嘉善县| 怀仁县| 弥勒县| 枞阳县| 太和县| 普格县| 哈尔滨市| 河池市| 榆树市| 定日县| 延安市| 仁布县| 元江| 崇明县| 道孚县| 韩城市| 五家渠市| 洞头县| 界首市| 怀来县| 桐梓县| 敖汉旗| 勐海县| 东山县| 丽江市| 松潘县| 太康县| 万荣县| 山丹县| 察隅县|