Example #1
0
        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)));
        }
Example #2
0
        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)));
        }
Example #3
0
        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);
        }
Example #4
0
 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;
 }
Example #5
0
        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);
        }
Example #6
0
        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)));
        }
Example #7
0
        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)
 {
 }
Example #9
0
 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);
 }
Example #10
0
 public MissConfigurationException(GathererConfigNode settingNode, string path)
     : this(new List <GathererConfigNode>() { settingNode }, path)
 {
 }