几个开源项目配置信息的存储和处理的方式

王朝other·作者佚名  2006-12-16
宽屏版  字体: |||超大  

最近在看duwamish7,asp.net forums, dottext几个优秀的开源(微软官方)的项目

因我目前所处的技术水平的阶段的原因,我看这些项目程序,更加关注的是具体的实现

次之才是架构

比较第一篇:几个开源项目实体层实现方式比较

这次的关注点是它们存储和处理配置信息的不同方式

一,duwamish7和asp.net forums

这两者处理方式有相同之处,都是通过实现IConfigurationSectionHandler来实现配置类

配置类的代码如下:

public class DuwamishConfiguration : IConfigurationSectionHandler

{

private static string dbConnectionString ;

private static bool enablePageCache ;

IConfigurationSectionHandler 成员#region IConfigurationSectionHandler 成员

public object Create(object parent, object configContext, System.Xml.XmlNode section)

{

NameValueCollection settings ;

try

{

NameValueSectionHandler baseHandler = new NameValueSectionHandler() ;

settings = (NameValueCollection)baseHandler.Create(parent,configContext,section) ;

}

catch

{

settings = null ;

}

if (settings != null)

{

dbConnectionString = (string)settings["dbConnectionString"] ;

enablePageCache = Convert.ToBoolean(settings["enablePageCache"]) ;

}

return setting

[1] [2] [3] [4] 下一页

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有