/// <summary> /// 获取配置实体 /// </summary> /// <param name="key"></param> /// <returns></returns> public static ConfigModel Get(string key = null, string projectName = null, string dbFile = "db.json") { var list = new List <ConfigModel>(); var item = new ConfigModel(); var cacheKey = "FastData.Core.Config"; if (DbCache.Exists(CacheType.Web, cacheKey)) { list = DbCache.Get <List <ConfigModel> >(CacheType.Web, cacheKey); } else if (projectName != null) { var assembly = Assembly.Load(projectName); using (var resource = assembly.GetManifestResourceStream(string.Format("{0}.{1}", projectName, dbFile))) { if (resource != null) { using (var reader = new StreamReader(resource)) { var content = reader.ReadToEnd(); list = BaseJson.JsonToList <ConfigModel>(BaseJson.ModelToJson(BaseJson.JsonToDic(content).GetValue("DataConfig"))); list.ForEach(a => { a.IsUpdateCache = false; }); DbCache.Set <List <ConfigModel> >(CacheType.Web, cacheKey, list); } } else { list = BaseConfig.GetListValue <ConfigModel>(AppSettingKey.Config, dbFile); DbCache.Set <List <ConfigModel> >(CacheType.Web, cacheKey, list); } } } else { list = BaseConfig.GetListValue <ConfigModel>(AppSettingKey.Config, dbFile); DbCache.Set <List <ConfigModel> >(CacheType.Web, cacheKey, list); } if (string.IsNullOrEmpty(key)) { item = list[0]; } else { item = list.Find(a => a.Key.ToLower() == key.ToLower()); } if (item.DesignModel == "") { item.DesignModel = Config.DbFirst; } if (item.SqlErrorType == "") { item.SqlErrorType = SqlErrorType.File; } if (item.CacheType == "") { item.CacheType = CacheType.Web; } item.IsPropertyCache = true; item.DbType = item.DbType.ToLower(); if (projectName != null) { item.IsUpdateCache = false; } return(item); }