using System.Collections.Generic; using System.Linq; using System.Xml; namespace BetterPatchFileCreator.Code { public class PatchConfigCollection : List { public void ReadFromFile(string path) { XmlDocument doc = new XmlDocument(); doc.Load(path); ParseFromXmlNode(doc); } public void ParseFromXmlNode(XmlNode node) { foreach (XmlNode n in node.ChildNodes) { PatchConfig config = new PatchConfig(); config.ReadFromXmlNode(n); this.Add(config); } } public XmlNode ToXmlNode(XmlDocument doc) { XmlNode root = doc.CreateElement("PatchConfigs"); foreach (var config in this) { root.AppendChild(config.ToXmlNode(doc)); } return root; } public PatchConfig this[string index]{ get { return this.FirstOrDefault(config => config.Name == index); } } } }