Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="XSimpleConfigurationSectionManager"/> class.
        /// </summary>
        public SimpleConfigurationSectionManager(string settings = null, string configPath = null)
        {
            if (settings == null)
            {
                return;
            }

            if (configPath == null)
            {
                var xmlConfigSection = (XmlNode)ConfigurationManager.GetSection(settings);
                if (xmlConfigSection != null)
                {
                    var cc = new ConfigNode(xmlConfigSection);
                    NodeAttributes = ConfigHelper.GetNodeChildAttributes(cc, ".");
                }
            }
            else
            {
                using (var configContainer = new ConfigContainer(configPath, "./rmqSettings"))
                {
                    var cc = configContainer.Node;
                    NodeAttributes = ConfigHelper.GetNodeChildAttributes(cc, ".");
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the node child attributes.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <param name="parentXPath">The parent x path.</param>
        /// <returns></returns>
        public static NodeChildAttributes GetNodeChildAttributes(IConfigNode node, string parentXPath)
        {
            var nca = new NodeChildAttributes();

            var pnode = node.GetConfigNode(parentXPath);

            if (pnode != null)
            {
                nca.ParentAttributes.NodeName = pnode.Name;
                nca.ParentAttributes.Attributes.Add(pnode.GetAttributes());

                var children = pnode.GetConfigNodes("./*");
                foreach (var cnode in children)
                {
                    var na = new NodeAttributes()
                    {
                        NodeName = cnode.Name
                    };
                    na.Attributes.Add(cnode.GetAttributes());
                    nca.ChildAttributes.Add(na);
                }
            }

            return(nca);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ConfigMultiSettings"/> class.
        /// </summary>
        /// <param name="container">The container.</param>
        /// <param name="parentXPath">The parent x path.</param>
        public ConfigMultiSettings(IConfigContainer container, string parentXPath)
        {
            _emptySettings = new NameValueCollection();
            _settings      = new Dictionary <string, NameValueCollection>();

            NodeChildAttributes nca = ConfigHelper.GetNodeChildAttributes(container, parentXPath);

            foreach (var attributes in nca.ChildAttributes)
            {
                if (attributes.Attributes.Count > 0)
                {
                    string key = attributes.Attributes[0];
                    _settings[key] = attributes.Attributes;
                }
            }
        }