Exemplo n.º 1
0
        private void resolveProperty(ConfigrationGroup group, string prefix, XmlNode node)
        {
            var property = new Property();

            property.Name = node.Name.ToLower();

            var value = node.GetAttribute(VALUE);

            if (value == null)
            {
                value = node.InnerText;
            }

            property.Segments = new PropertyParser().Parse(value);

            group.AddProperty(property);

            //do recursive
            foreach (var subNode in node.ChildNodes)
            {
                var propertyNode = subNode as XmlNode;

                resolveProperty(group, property.Name + ".", propertyNode);
            }
        }
Exemplo n.º 2
0
        public ConfigrationGroup[] Resolve(string path)
        {
            var ls = new List <ConfigrationGroup>();

            var xml = new XmlDocument();

            _loadedPathes.Add(path);

            xml.Load(path);

            foreach (var groupNode in xml.GetAll(x => x.Name == CONFIG_GROUP))
            {
                var name = groupNode.GetAttribute(NAME);

                requireAttributeExists(name, CONFIG_GROUP, NAME);

                var group = new ConfigrationGroup(name);

                foreach (var property in groupNode)
                {
                    var propertyNode = property as XmlNode;

                    if (propertyNode.Name == IMPORT)
                    {
                        var outterPath = propertyNode.GetAttribute(PATH);

                        requireAttributeExists(name, IMPORT, PATH);

                        if (!_loadedPathes.Contains(outterPath))
                        {
                            ls.AddRange(Resolve(outterPath));
                        }
                    }
                    else
                    {
                        resolveProperty(group, "", propertyNode);
                    }
                }

                ls.Add(group);
            }

            return(ls.ToArray());
        }