web.configファイルの研究

まず、構成がクラスにマッピングされました

1、構成が増加します

    <configSections> 
        <セクション名= " appConfiguration "タイプ= " OilDigital.CGGL.AppConfig.AppConfigurationHandler、OilDigital.CGGL.AppConfig、カルチャニュートラル、PublicKeyToken = = null " /> 
        
    </ configSections> 
<appConfiguration> 
        < EnterPriseName > 中石油 </ EnterPriseName > 
</ appConfiguration>

2、クラス

パブリック クラスAppConfiguration:System.Configuration.ConfigurationSection 
    { 
        パブリックAppConfiguration()
        { 
            
        } 

        ///  <要約> 
        /// 企业名称
         ///  </要約> 
        [ConfigurationProperty(" EnterPriseName "、のDefaultValue = " 工程建设公司" )]
         パブリック 文字列  EnterPriseName 
        { 
            取得 { 戻り文字列この [ " EnterPriseName " ]。}
            セット { この [ " EnterPriseName " ] = 値。} 
        } 
}

使用して3、

AppConfigurationコンフィグ=(AppConfiguration)System.Configuration.ConfigurationManager.GetSection(" appConfiguration ")。

 

おすすめ

転載: www.cnblogs.com/zhengwei-cq/p/11760486.html