[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代码分析篇

posted @ 2004-11-03 21:37  cacard  阅读(1513)  评论(0编辑  收藏  举报