protected virtual bool Load(IConfiguration Items) { //log.Debug("Load configuration: " + _URI); if (_URI != "" && File.Exists(_URI)) { _Configuration = new XmlDocument(); try { _Configuration.Load(_URI); if (Items != null) { foreach (XmlNode node in _Configuration.DocumentElement.ChildNodes) { IConfigurationItem newItem = IConfigurationItemImpl.FromXml(node, _Source); newItem.Name = string.Format("item-{0}", Items.Items.Count + 1); Items.Items.Add(newItem); } } return(true); } catch (Exception exc) { log.Debug(exc.ToString()); } } //if (_URI != "" && File.Exists(_URI)) return(false); } //protected virtual bool Load()
public static IConfigurationItem FromXml(XmlNode Node, eConfigurationSource target) { IConfigurationItem result = new IConfigurationItemImpl("", Node.InnerText, target); result.StorageKey = Node.Attributes[tag_key_attribute] != null ? Node.Attributes[tag_key_attribute].InnerText : ""; result.Type = Node.Attributes[tag_type_attribute] != null ? Node.Attributes[tag_type_attribute].InnerText : ""; return(result); }
protected void DefineConfiguration() { if (conf != null) { IConfigurationItem item = new IConfigurationItemImpl(Name, "", _ConfigurationSource); conf.AddConfigurationItem(_Prefix, item); conf.AddConfigurationItem(_Prefix, new IConfigurationItemImpl( (this as IConfigurationControl).ConfigurationName(), "", _ConfigurationSource)); } }
} //bool IConfigurationItem.SetValue( bool IConfigurationItem.SetValue(XmlNode newValue, eConfigurationSource source) { if (newValue != null && IsSourceAllowed(source)) { if (newValue.Attributes[tag_definition_attribute] != null) { _ConfigurationItemValueType = (eConfigurationItemValueType)Enum.Parse(typeof(eConfigurationItemValueType), newValue.Attributes[tag_definition_attribute].InnerText, true); bool result = false; switch (_ConfigurationItemValueType) { case eConfigurationItemValueType.plain: if (newValue.ChildNodes.Count >= 1 && newValue.ChildNodes[0].GetType() == typeof(XmlElement)) { (this as IConfigurationItem).Clear(); foreach (XmlNode node in newValue) { IConfigurationItem item = new IConfigurationItemImpl(node.Name); if (node.Attributes[tag_key_attribute] != null) { item.StorageKey = node.Attributes[tag_key_attribute].InnerText; } item.SetValue(node, source); item.Source = source; item.Target = _Target; _Source = source; _ConfigurationItems.Add(item); } //foreach (XmlNode node in newValue) } //if (newValue.ChildNodes.Count > 1) else { _Value = GetNodeValue(newValue); } result = true; break; case eConfigurationItemValueType.xml: _Value = GetNodeValue(newValue); result = true; break; case eConfigurationItemValueType.list: (this as IConfigurationItem).Clear(); foreach (XmlNode node in newValue) { IConfigurationItem item = new IConfigurationItemImpl("item" + Convert.ToString(_ConfigurationItems.Count + 1)); item.SetValue(node, source); item.Source = source; item.Target = _Target; _Source = source; _ConfigurationItems.Add(item); } //foreach (XmlNode node in newValue) result = true; break; } //switch (_ConfigurationItemValueType) return(result); } //if (newValue.Attributes[tag_definition_attribute] != null) switch (newValue.ChildNodes.Count) { case 0: case 1: if (_IsCollection) { (this as IConfigurationItem).Clear(); foreach (XmlNode node in newValue) { IConfigurationItem item = new IConfigurationItemImpl(node.Name); item.SetValue(node, source); _Source = source; _ConfigurationItems.Add(item); } //foreach (XmlNode node in newValue) } //if (_IsCollection) else { InternalValue = GetNodeValue(newValue); } break; default: (this as IConfigurationItem).Clear(); foreach (XmlNode node in newValue) { IConfigurationItem item = new IConfigurationItemImpl(node.Name); item.SetValue(node, source); _ConfigurationItems.Add(item); } //foreach (XmlNode node in newValue) break; } //switch(newValue.ChildNodes.Count) _Source = source; return(true); } //if (newValue != null && (_Source ... return(false); } //bool IConfigurationItem.SetValue(