public static XMLSetting Load(string filePath) { try { return(XMLSetting.Load(File.OpenText(filePath))); } catch (Exception ex) { if (ex is ThreadAbortException) { throw ex; } return(null); } }
public XMLSetting Clone() { var xmlSetting = new XMLSetting(); foreach (XMLTabCollectionSettingsItem visibleSetting in VisibleSettings) { xmlSetting.VisibleSettings.Add(visibleSetting.Clone()); } foreach (XMLSettingsItem invisibleSetting in InvisibleSettings) { xmlSetting.InvisibleSettings.Add(invisibleSetting.Clone()); } return(xmlSetting); }
public static XMLSetting Load(TextReader inputReader) { var xmlSetting = (XMLSetting)null; try { using (var xmlReader = XmlReader.Create(inputReader)) { xmlSetting = (XMLSetting) new XmlSerializer(typeof(XMLSetting)).Deserialize(xmlReader); } } catch (Exception ex) { if (ex is ThreadAbortException) { throw ex; } return(null); } var stringSet = new HashSet <string>(); var crossCheckName = new HashSet <string>(); for (var index = 0; index < xmlSetting.VisibleSettings.Count; ++index) { XMLTabCollectionSettingsItem visibleSetting = xmlSetting.VisibleSettings[index]; var header = visibleSetting.Header; if (header == null) { throw new Exception("XMLSetting.UserViewableSettings contains a tab without a Header string!"); } if (stringSet.Contains(header)) { throw new Exception(string.Format("Tabs must have unique text! \"{0}\" has duplicates", header)); } stringSet.Add(header); XMLSetting.CheckNamesAndText_Helper(crossCheckName, visibleSetting.Items, true); } XMLSetting.CheckNamesAndText_Helper(crossCheckName, xmlSetting.InvisibleSettings, false); return(xmlSetting); }