using System; using System.Collections.Generic; using System.Text; using Zhaizj.Framework.Config.DotNetConfig; using System.Configuration; namespace Zhaizj.Framework.Data.Config { /// /// 数据库配置方式 /// /// /// 配置文件格式和说明: /// /// /// ; ///
; /// /// /// /// /// /// /// ...... /// /// public class SectionDataHandler : SectionBaseHandler { /// /// 配置数据库连接 /// [ConfigurationProperty("ConnectionStringTable", DefaultValue = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=zhaizj.mdb")] public string ConnectionStringTable { get { return (string)this["ConnectionStringTable"]; } } /// /// 配置数据库类型 /// [ConfigurationProperty("DbType", DefaultValue = "access")] public string DbType { get { return (string)this["DbType"]; } } /// /// 配置多数据库 /// [ConfigurationProperty("Mapping", DefaultValue = "")] public string Mapping { get { return (string)this["Mapping"]; } } /// ///是否启用缓存 /// [ConfigurationProperty("ApplicationCache", DefaultValue = "false")] public string ApplicationCache { get { return (string)this["ApplicationCache"]; } } /// ///设置缓存时间-999 是永久缓存 /// [ConfigurationProperty("ApplicationCacheMinutes", DefaultValue = "-999")] public string ApplicationCacheMinutes { get { return (string)this["ApplicationCacheMinutes"]; } } /// ///缓存管理 /// [ConfigurationProperty("ApplicationCacheManager", DefaultValue = "")] public string ApplicationCacheManager { get { return (string)this["ApplicationCacheManager"]; } } /// //程序集初始化 /// [ConfigurationProperty("AssemblyList", DefaultValue = "Zhaizj.CoreApps")] public string AssemblyList { get { return (string)this["AssemblyList"]; } } /// /// 拦截器 /// [ConfigurationProperty("Interceptor", DefaultValue = "Zhaizj.CoreApps")] public string Interceptor { get { return (string)this["Interceptor"]; } } /// /// 拼接代码 /// /// public string GetDataConfig() { StringBuilder tagData = new StringBuilder(); tagData.Append("{"); tagData.Append("ConnectionStringTable : {default:\"" + ConnectionStringTable + "\"},"); tagData.Append("DbType : { default:\"" + DbType + "\"},"); tagData.Append("Mapping:[" + Mapping + "],"); tagData.Append("ApplicationCache:" + ApplicationCache + ","); tagData.Append("ApplicationCacheMinutes:" + ApplicationCacheMinutes + ","); tagData.Append("ApplicationCacheManager:\"" + ApplicationCacheManager + "\","); tagData.Append("AssemblyList : [\"" + AssemblyList + "\"], Interceptor:[]"); tagData.Append("}"); return tagData.ToString(); } } }