public static object GetConfigByType(Type t) { if (_dic.ContainsKey(t)) { return(_dic[t]); } object[] bkatts = t.GetCustomAttributes(typeof(MDConfigAttribute), false); if (bkatts == null || bkatts.Length == 0) { return(null); } MDConfigAttribute att = bkatts[0] as MDConfigAttribute; Sys_Configuration item = new Sys_Configuration(); item.Module = att.Module; item.Functions = att.Functions; var query = _db.SysConfigurations.Where(c => c.Domain == _appDomain).Where(a => a.Module == item.Module).Where(b => b.Functions == item.Functions).ToList(); if (query != null && query.Count > 0) { object ret = t.Assembly.CreateInstance(t.ToString()); foreach (var i in query) { var property = ret.GetType().GetProperty(i.Keys); if (property != null) { property.SetValue(ret, i.Value); } } _dic[t] = ret; return(ret); } return(null); }
/// <summary> /// 检查配置 /// </summary> /// <param name="ConfigurationName">配置名称</param> /// <returns></returns> public static string CheckConfiguration(string ConfigurationName) { try { if (string.IsNullOrEmpty(ConfigurationName)) { return(string.Empty); } List <Sys_Configuration> SysConfigurations = new List <Sys_Configuration>(); SysConfigurations = (List <Sys_Configuration>)Provider.Get("SysConfiguration"); Sys_Configuration SysConfiguration = SysConfigurations.FirstOrDefault(c => c.Configuration_Name.ToUpper() == ConfigurationName.ToUpper()); if (SysConfiguration != null) { return(SysConfiguration.Configuration_Value); } return(string.Empty); } catch (Exception ex) { return(ex.Message); } }