public IConfigurationObject this[string name] { get { if (this.configurations.Contains((object)name)) { return((IConfigurationObject)this.configurations[(object)name]); } ConfigurationObject configurationObject = new ConfigurationObject(); this.configurations[(object)name] = (object)configurationObject; return((IConfigurationObject)configurationObject); } set { if (value == null) { if (!this.configurations.Contains((object)name)) { return; } this.configurations.Remove((object)name); } else { this.configurations[(object)name] = (object)value; } } }
internal void Load(XmlReader reader) { while (reader.IsStartElement("ConfigurationObject")) { bool isEmptyElement = reader.IsEmptyElement; reader.ReadStartElement("ConfigurationObject"); ConfigurationObject configurationObject = new ConfigurationObject(); this.Add((IConfigurationObject)configurationObject); if (!isEmptyElement) { configurationObject.Load(reader); reader.ReadEndElement(); } } }
internal void Load(XmlReader reader) { while (reader.IsStartElement()) { bool isEmptyElement = reader.IsEmptyElement; string attribute1 = reader.GetAttribute("Name"); if (reader.IsStartElement("PrimitiveObject")) { string attribute2 = reader.GetAttribute("Type"); reader.ReadStartElement("PrimitiveObject"); if (!isEmptyElement) { string text = reader.ReadString(); reader.ReadEndElement(); Type type = !string.IsNullOrEmpty(attribute2) ? Type.GetType(attribute2) : typeof(string); if (type != (Type)null) { TypeConverter converter = TypeDescriptor.GetConverter(type); if (converter != null) { try { object obj = converter.ConvertFromString((ITypeDescriptorContext)null, CultureInfo.InvariantCulture, text); this.SetProperty(attribute1, obj); } catch (NotSupportedException ex) { } catch (FormatException ex) { } } } } } else if (reader.IsStartElement("ConfigurationObject")) { reader.ReadStartElement("ConfigurationObject"); ConfigurationObject configurationObject = (ConfigurationObject)this.CreateConfigurationObject(); this.SetProperty(attribute1, (object)configurationObject); if (!isEmptyElement) { configurationObject.Load(reader); reader.ReadEndElement(); } } else { if (!reader.IsStartElement("ConfigurationObjectCollection")) { throw new NotSupportedException(); } reader.ReadStartElement("ConfigurationObjectCollection"); ConfigurationObjectCollection objectCollection = (ConfigurationObjectCollection)this.CreateConfigurationObjectCollection(); this.SetProperty(attribute1, (object)objectCollection); if (!isEmptyElement) { objectCollection.Load(reader); reader.ReadEndElement(); } } } }