public bool Contains(string path) { path = path.Replace("\\", "/"); int f = path.IndexOf("/"); if (f == -1) { string v; bool hasAttr = Attributes.TryGetValue(path, out v); if (hasAttr) { return(true); } return(Nodes.Any(o => o.Name == path)); } string name = path.Substring(0, f); GathererConfigNode node = Nodes.FirstOrDefault(o => o.Name == name); if (node == null) { return(false); } return(node.Contains(path.Substring(f + 1))); }
public string TryGetValue(string path) { path = path.Replace("\\", "/"); int f = path.IndexOf("/"); if (f == -1) { string v; if (Attributes.TryGetValue(path, out v)) { return(v); } return(null); } string name = path.Substring(0, f); GathererConfigNode node = Nodes.FirstOrDefault(o => o.Name == name); if (node == null) { return(null); } return(node.TryGetValue(path.Substring(f + 1))); }
protected override void DeserializeElement(System.Xml.XmlReader reader, bool serializeCollectionKey) { string xml = reader.ReadOuterXml(); XDocument doc = XDocument.Parse(xml); rootNode = GathererConfigNode.ConvertFrom((XElement)doc.FirstNode, null); }
public static GathererConfigNode ConvertFrom(XElement element, GathererConfigNode parent) { GathererConfigNode node = new GathererConfigNode(); node.Name = element.Name.LocalName; node.Parent = parent; node.Attributes = element.Attributes().ToDictionary(o => o.Name.LocalName, o => o.Value); node.Nodes = element.Elements().Select(o => ConvertFrom(o, node)); return node; }
public static GathererConfigNode ConvertFrom(XElement element, GathererConfigNode parent) { GathererConfigNode node = new GathererConfigNode(); node.Name = element.Name.LocalName; node.Parent = parent; node.Attributes = element.Attributes().ToDictionary(o => o.Name.LocalName, o => o.Value); node.Nodes = element.Elements().Select(o => ConvertFrom(o, node)); return(node); }
public GathererConfigNode TryGetNode(string path) { path = path.Replace("\\", "/"); int f = path.IndexOf("/"); if (f == -1) { return(Nodes.FirstOrDefault(o => o.Name == path)); } string name = path.Substring(0, f); GathererConfigNode node = Nodes.FirstOrDefault(o => o.Name == name); if (node == null) { return(null); } return(node.TryGetNode(path.Substring(f + 1))); }
public IEnumerable <GathererConfigNode> TryGetNodes(string path) { path = path.Replace("\\", "/"); int f = path.IndexOf("/"); if (f == -1) { return(Nodes.Where(o => o.Name == path)); } string name = path.Substring(0, f); GathererConfigNode node = Nodes.FirstOrDefault(o => o.Name == name); if (node == null) { return(new List <GathererConfigNode>()); } return(node.TryGetNodes(path.Substring(f + 1))); }
public MissConfigurationException(GathererConfigNode settingNode, string path) : this(new List<GathererConfigNode>() { settingNode }, path) { }
protected override void DeserializeElement(System.Xml.XmlReader reader, bool serializeCollectionKey) { string xml = reader.ReadOuterXml(); XDocument doc = XDocument.Parse(xml); rootNode = GathererConfigNode.ConvertFrom((XElement)doc.FirstNode, null); }
public MissConfigurationException(GathererConfigNode settingNode, string path) : this(new List <GathererConfigNode>() { settingNode }, path) { }