zoukankan      html  css  js  c++  java
  • [Duwamish]读取web.config配置节的一个过程

    (1)访问Duwamish,执行Global.asax的Application_OnStart()

    void Application_OnStart()
        
    {
            ApplicationConfiguration.OnApplicationStart(Context.Server.MapPath( Context.Request.ApplicationPath ));
     
    string configPath = Path.Combine(Context.Server.MapPath( Context.Request.ApplicationPath ),"remotingclient.cfg");
     
    if(File.Exists(configPath))
      RemotingConfiguration.Configure(configPath);
     
        }

    (2)调用ApplicationConfiguration.OnApplicationStart(Context.Server.MapPath( Context.Request.ApplicationPath ));

            public static void OnApplicationStart(String myAppPath)
            
    {
                appRoot 
    = myAppPath;
                System.Configuration.ConfigurationSettings.GetConfig(
    "ApplicationConfiguration");
                System.Configuration.ConfigurationSettings.GetConfig(
    "DuwamishConfiguration");
                System.Configuration.ConfigurationSettings.GetConfig(
    "SourceViewer");
                
            }

    (3)System.Configuration.ConfigurationSettings.GetConfig("DuwamishConfiguration");并没有返回什么,目的是调用:

    Common.DuwamishConfiguration.Create()方法,填充静态字段:
     private static String dbConnectionString;等.

    (4)可以直接使用DuwamishConfiguration.ConnectionString进行读取.

    参考:Duwamish代码分析篇

  • 相关阅读:
    闭包函数+装饰器(第十一天)
    函数初接触2
    函数初接触
    第八天
    第八天
    第七天
    day4—day6作业(补发)
    第六天
    第五天
    python基础学习-常用模块的使用(扩展补充,高级使用)(三)
  • 原文地址:https://www.cnblogs.com/caca/p/60133.html
Copyright © 2011-2022 走看看