websharp配置文件

首先和其它的一样要在Web.config中配置
None.gif   < appSettings >
None.gif    
< add key = " DBConnString "  value = " server=.;User ID=sa;Password=;database=news1 ; " />
None.gif    
< add key = " EntityPath "  value = " ~/EntityDefine/ "   />
None.gif    
< add key = " DBType "  value = " sqlserver "   />
None.gif    
< add key = " CachedConn "  value = " 4 "   />
None.gif    
< add key = " UFServer "  value = " 192.168.0.213 "   />
None.gif    
< add key = " UFUser "  value = " sa "   />
None.gif    
< add key = " UFPwd "  value = ""   />
None.gif 
</ appSettings >   

其次在Global.asax中Application_Start加入
None.gif     IAppConfigSetter setter = new  AppConfigSetter();
None.gif            ApplicationConfiguration.SetAppConfiguration(setter);    

是为了生成配置文件
再次建立以个类AppConfigSetter.cs
None.gif public   class  AppConfigSetter :System.Web.UI.Page, IAppConfigSetter
ExpandedBlockStart.gifContractedBlock.gif    
dot.gif {
InBlock.gif        
//得到当前数据连接
InBlock.gif
        public  string GetDBConnectionString ()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
return ConfigurationSettings.AppSettings["DBConnString"];
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
public string GetDBType()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
return ConfigurationSettings.AppSettings["DBType"];
ExpandedSubBlockEnd.gif        }

InBlock.gif        
//得到实体定义XML文件的路径
InBlock.gif
        public string GetEntityDefinitionPath()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
return Server.MapPath(ConfigurationSettings.AppSettings["EntityPath"]);
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
//得到连接池的大小
InBlock.gif
        public int GetPooledConnectionCount()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
return int.Parse(ConfigurationSettings.AppSettings["CachedConn"]);
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif
//        //得到其他数据库连接
InBlock.gif
        public NameValueCollection GetOtherCollections()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
return ConfigurationSettings.AppSettings;
InBlock.gif            
InBlock.gif
//            return (new test_websharp.ZTConfigDB()).GetZT();
ExpandedSubBlockEnd.gif
        }

ExpandedBlockEnd.gif    }
这样它的基础配置就完成了。

转载于:https://www.cnblogs.com/gjahead/archive/2006/06/29/438262.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值