internal override void AddChild(ConfigurationElement child) { ForceLoad(); if (Schema.CollectionSchema.ContainsAddElement(child.ElementTagName)) { child.AppendToParentElement(child.Entity, false); Real.Add(child); if (HasParent && Schema.Path == "system.webServer/defaultDocument/files") { var index = Real.Count == 0 ? 0 : Exposed.IndexOf(Real[Real.Count - 1]) + 1; Exposed.Insert(index, child); } else { Exposed.Add(child); } } else if (child.ElementTagName == Schema.CollectionSchema.ClearElementName) { child.AppendToParentElement(child.Entity, false); Real.Add(child); Exposed.Clear(); } else if (child.ElementTagName == Schema.CollectionSchema.RemoveElementName) { child.AppendToParentElement(child.Entity, false); Real.Add(child); foreach (var item in Exposed.ToList()) { if (Match(item, child, Schema.CollectionSchema.RemoveSchema)) { // IMPORTANT: can remove from location tag in the same file, but not from child web.config. if (item.IsLocked == "true" && item.CloneSource?.FileContext != FileContext) { throw new FileLoadException($"Filename: \\\\?\\{FileContext.FileName}\r\nLine number: {(child.Entity as IXmlLineInfo).LineNumber}\r\nError: Lock violation\r\n\r\n"); } Exposed.Remove(item); } } } else { base.AddChild(child); } }
internal override void AddChild(ConfigurationElement child) { ForceLoad(); if (Schema.CollectionSchema.ContainsAddElement(child.ElementTagName)) { child.AppendToParentElement(child.Entity, false); Real.Add(child); if (HasParent && Schema.Path == "system.webServer/defaultDocument/files") { var index = Real.Count == 0 ? 0 : Exposed.IndexOf(Real[Real.Count - 1]) + 1; Exposed.Insert(index, child); } else { Exposed.Add(child); } } else if (child.ElementTagName == Schema.CollectionSchema.ClearElementName) { child.AppendToParentElement(child.Entity, false); Real.Add(child); Exposed.Clear(); } else if (child.ElementTagName == Schema.CollectionSchema.RemoveElementName) { child.AppendToParentElement(child.Entity, false); Real.Add(child); foreach (var item in Exposed.ToList()) { if (Match(item, child, Schema.CollectionSchema.RemoveSchema)) { Exposed.Remove(item); } } } else { base.AddChild(child); } }