コード例 #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)));
        }
コード例 #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)));
        }
コード例 #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);
        }
コード例 #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;
 }
コード例 #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);
        }
コード例 #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)));
        }
コード例 #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)));
        }
コード例 #8
0
 public MissConfigurationException(GathererConfigNode settingNode, string path)
     : this(new List<GathererConfigNode>() { settingNode }, path)
 {
 }
コード例 #9
0
ファイル: GathererSection.cs プロジェクト: jorson/metis_sdk
 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);
 }
コード例 #10
0
 public MissConfigurationException(GathererConfigNode settingNode, string path)
     : this(new List <GathererConfigNode>() { settingNode }, path)
 {
 }