private static ConfigGroupsSettings GetConfigSettings() { if (config_settings == null || config_settings.xmlGroups == null || config_settings.xmlSheetGroups == null || (config_settings.xmlGroups.Length <= 0 && config_settings.xmlSheetGroups.Length <= 0)) { config_settings = null; if (File.Exists(SETTINGS_FILE_PATH)) { XSerializer x = new XSerializer(typeof(ConfigGroupsSettings)); StreamReader reader = File.OpenText(SETTINGS_FILE_PATH); try { config_settings = (ConfigGroupsSettings)x.Deserialize(reader); if (config_settings.xmlGroups == null) { config_settings.xmlGroups = new XmlGroupSettings[0]; } if (config_settings.xmlSheetGroups == null) { config_settings.xmlSheetGroups = new XmlSheetGroupSettings[0]; } } catch { } reader.Close(); } if (config_settings == null) { config_settings = new ConfigGroupsSettings(); config_settings.xmlGroups = new XmlGroupSettings[0]; config_settings.xmlSheetGroups = new XmlSheetGroupSettings[0]; } } return(config_settings); }
public static void WriteXmlGroupSettings(List <XmlGroupSettings> settings) { if (settings == null) { return; } ConfigGroupsSettings groups = GetConfigSettings(); groups.xmlGroups = settings.ToArray(); WriteConfigSettings(); }