private AddChild ( |
||
child | ||
return | void |
internal void Clone(ConfigurationElement item, ConfigurationElement newItem) { newItem.SkipCheck = true; foreach (ConfigurationAttribute attribute in item.Attributes) { newItem[attribute.Name] = item[attribute.Name]; } foreach (ConfigurationElement child in item.ChildElements) { var newChild = newItem.ChildElements[child.ElementTagName]; Clone(child, newChild); } if (item is ConfigurationElementCollection collection) { foreach (ConfigurationElement element in collection) { var newElement = ((ConfigurationElementCollection)newItem).CreateNewElement(element.ElementTagName); Clone(element, newElement); newItem.AddChild(newElement); } } newItem.IsLocked = item.IsLocked; newItem.SkipCheck = false; }
private bool ParseSections(XElement element, ConfigurationElement parent, Location location) { var result = false; var path = element.GetPath(); ConfigurationElement node = null; var schema = FindSchema(path); var sec = FindSectionSchema(path); var name = element.Name.LocalName; if (schema != null) { if (sec != null) { var section = new ConfigurationSection(path, sec.Root, location?.Path, this, element); RootSectionGroup.Add(section, location); node = section; } else { node = schema.CollectionSchema == null ? new ConfigurationElement(null, name, schema, parent, element, this) : new ConfigurationElementCollection( name, schema, parent, element, this); } parent?.AddChild(node); result = true; } else { var found = RootSectionGroup.GetSectionDefinition(path); if (found != null && found.Ignore && path != "system.webServer") { return(true); } } foreach (var item in element.Nodes()) { var child = item as XElement; if (child == null) { continue; } var childAdded = ParseSections(child, node, location); result = result || childAdded; } if (!result && !_dontThrow && name != "location") { throw new COMException( string.Format( "Line number: {0}\r\nError: Unrecognized element '{1}'\r\n", (element as IXmlLineInfo).LineNumber, name)); } return(result); }