Esempio n. 1
0
        /// <summary>
        /// 加载配置文件,并且封装配置信息
        /// </summary>
        /// <returns></returns>
        public static CommConfig GetConfig()
        {
            CommConfig config = MangaCache.GetLocal(GlobalKey.COMMCONFIG) as CommConfig;//尝试从缓存获取配置信息类

            if (config == null)
            {
                //当缓存中不存在时建立
                string      path = GetFilePath();
                XmlDocument doc  = new XmlDocument();
                doc.Load(path);
                config = new CommConfig(doc);
                MangaCache.MaxLocalWithFile(GlobalKey.COMMCONFIG, config, path);
            }
            return(config);
        }
Esempio n. 2
0
        /// <summary>
        /// 从配置文件加载数据库访问提供者类
        /// </summary>
        /// <param name="providerName">提供者名</param>
        /// <returns>漫画提供者</returns>
        public static CommonDataProvider Instance(string providerName)
        {
            string             cachekey = GlobalKey.PROVIDER + "_" + providerName;
            CommonDataProvider objType  = MangaCache.GetLocal(cachekey) as CommonDataProvider;//从缓存读取

            if (objType == null)
            {
                CommConfig config       = CommConfig.GetConfig();
                Provider   dataProvider = (Provider)config.Providers[providerName];
                objType = DataProvider.Instance(dataProvider) as CommonDataProvider;
                string      path    = null;
                HttpContext context = HttpContext.Current;
                if (context != null)
                {
                    path = context.Server.MapPath("~/config/common.config");
                }
                else
                {
                    path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"config\common.config");
                }
                MangaCache.MaxLocalWithFile(cachekey, objType, path);
            }
            return(objType);
        }