public bool SaveConfig(BaseConfig model) { //return SerializationHelper.Save(model, this.xmlpath); Type type = model.GetType(); Lebi_Config cf; foreach (System.Reflection.PropertyInfo p in type.GetProperties()) { if (p.GetValue(model, null) == null) { continue; } cf = B_Lebi_Config.GetModel("Name='" + p.Name + "'"); if (cf == null) { cf = new Lebi_Config(); cf.Name = p.Name; cf.Value = p.GetValue(model, null).ToString(); B_Lebi_Config.Add(cf); } else { cf.Name = p.Name; cf.Value = p.GetValue(model, null).ToString(); B_Lebi_Config.Update(cf); } } ShopCache.SetBaseConfig();//更新缓存 return(true); }
/// <summary> /// 设置一个设置值 /// </summary> /// <param name="key"></param> /// <param name="value"></param> public static void Set(string key, string value) { Lebi_Config conf = B_Lebi_Config.GetModel("Name='" + key + "'"); if (conf == null) { conf = new Lebi_Config(); conf.Name = key; conf.Value = value; B_Lebi_Config.Add(conf); } else { conf.Value = value; B_Lebi_Config.Update(conf); } }