예제 #1
0
        public XMLTabCollectionSettingsItem Clone()
        {
            var collectionSettingsItem = new XMLTabCollectionSettingsItem
            {
                Header = Header
            };

            foreach (XMLSettingsItem xmlSettingsItem in Items)
            {
                collectionSettingsItem.Items.Add(xmlSettingsItem.Clone());
            }

            return(collectionSettingsItem);
        }
예제 #2
0
        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);
        }