public string SaveConfiguration <T>(string configStoreInfor, T configInfor) where T : class { if (string.IsNullOrEmpty(configStoreInfor) || configInfor == null) { return("100001"); } string storeFileName = GetCacheInfor(configStoreInfor); if (!File.Exists(storeFileName)) { return("100003"); } bool saveFlag = ObjectXmlSerializer.SaveXmlToFlie <T>(storeFileName, configInfor); if (saveFlag) { return(string.Empty); } else { return("100004"); } }
public static bool SaveConfig <T>(T t) where T : class, new() { ConfigFileAttribute attribute = AttributeHelper.GetConfigAttribute <ConfigFileAttribute>(typeof(T)); if (attribute == null) { ConfigThrowHelper.ThrowConfigException( R.ConfigError_NoConfigAttribute, typeof(T).FullName, typeof(ConfigFileAttribute).FullName); } ConfigSettings configSettings = FrameworkConfig.GetConfig <ConfigSettings>(); string configFilePath = string.Empty; switch (attribute.ConfigPathType) { case ConfigPathType.FullPhysicalPath: configFilePath = attribute.FileName; break; case ConfigPathType.ServerPath: configFilePath = HttpContext.Current.Server.MapPath(attribute.FileName); break; default: configFilePath = configSettings.GetConfigFilePath <T>(); break; } XmlConfigGetParameter getParameter = new XmlConfigGetParameter(configFilePath, attribute.IncludeSubdirectories); return(ObjectXmlSerializer.SaveXmlToFlie <T>(getParameter.FilePaths, t)); }