public XmlNode GetNode(string xPath)
        {
            if (XmlSection == null)
            {
                return(null);
            }

            return(XmlSection.SelectSingleNode(xPath));
        }
        public string GetAttribute(string xPath, string attName, string defaultValue)
        {
            if (XmlSection == null)
            {
                return(defaultValue);
            }

            return(GetAttribute(XmlSection.SelectSingleNode(xPath), attName, defaultValue));
        }
        internal FilterInfo GetFilterInfo(string name)
        {
            if (XmlSection == null)
            {
                return(null);
            }

            var xPath   = string.Format("./filters/filter[@name='{0}']", name);
            var objNode = XmlSection.SelectSingleNode(xPath);

            if (objNode == null)
            {
                return(null);
            }

            // validate info
            var sMode = GetAttribute(objNode, "mode", "include").Trim().ToLower();

            if (!(sMode == "include" || sMode == "exclude"))
            {
                return(null);
            }

            var mode   = sMode == "include" ? FilterMode.Include : FilterMode.Exclude;
            var filter = new FilterInfo(name.Trim().ToLower(), mode);

            foreach (XmlNode childNode in objNode.ChildNodes)
            {
                if (childNode.Name != "method" || childNode.Attributes["type"] == null)
                {
                    continue;
                }

                string[] methods = childNode.Attributes["type"].Value.Split(',');
                foreach (string method in methods)
                {
                    filter.IDs.Add(method.Trim());
                }
            }

            return(filter);
        }
        internal List <RIInstance> LoadLogManagerInstances()
        {
            var instances = new List <RIInstance>();

            if (XmlSection == null)
            {
                return(instances);
            }

            var objNode = XmlSection.SelectSingleNode("./logManager");

            if (objNode == null)
            {
                return(instances);
            }

            foreach (XmlNode node in objNode.ChildNodes)
            {
                if (node.Name != "instance")
                {
                    continue;
                }
                if (node.Attributes["name"] == null)
                {
                    continue;
                }

                string name     = node.Attributes["name"].Value;
                string category = node.Attributes["category"] != null ? node.Attributes["category"].Value : string.Empty;
                string bkColor  = node.Attributes["bkColor"] != null ? node.Attributes["bkColor"].Value : string.Empty;
                string destinationBindingGroup = node.Attributes["destinationBindingGroup"] != null ? node.Attributes["destinationBindingGroup"].Value : string.Empty;

                instances.Add(new RIInstance(name, category, bkColor, destinationBindingGroup));
            }

            return(instances);
        }
        internal Hashtable LoadMessageColors()
        {
            var messageColors = new Hashtable();

            if (XmlSection == null)
            {
                return(messageColors);
            }

            var objNode = XmlSection.SelectSingleNode("./messageColors");

            if (objNode == null)
            {
                return(messageColors);
            }

            foreach (XmlNode node in objNode.ChildNodes)
            {
                if (node.Name != "message")
                {
                    continue;
                }
                if (node.Attributes["type"] == null)
                {
                    continue;
                }
                if (node.Attributes["bkColor"] == null)
                {
                    continue;
                }

                messageColors[node.Attributes["type"].Value] = node.Attributes["bkColor"].Value;
            }

            return(messageColors);
        }
        internal List <ListenerGroup> LoadListenerGroups()
        {
            var groups = new List <ListenerGroup>();

            if (XmlSection == null)
            {
                return(groups);
            }

            var objNode = XmlSection.SelectSingleNode("./listenerGroups");

            if (objNode == null)
            {
                return(groups);
            }

            foreach (XmlNode gNode in objNode.ChildNodes)
            {
                if (gNode.Name != "group")
                {
                    continue;
                }
                if (gNode.Attributes["name"] == null)
                {
                    continue;
                }

                var name     = gNode.Attributes["name"].Value;
                var bEnabled = (gNode.Attributes["enabled"] != null ? gNode.Attributes["enabled"].Value : "true") == "true";
                var bMask    = (gNode.Attributes["maskIdentities"] != null ? gNode.Attributes["maskIdentities"].Value : "false") == "true";

                var group = new ListenerGroup(name, bEnabled, bMask);
                groups.Add(group);

                // let's add the destinations
                XmlNode destNodes = gNode.SelectSingleNode("./destinations");
                if (destNodes != null)
                {
                    foreach (XmlNode dNode in destNodes.ChildNodes)
                    {
                        if (dNode.Name != "destination")
                        {
                            continue;
                        }

                        if (dNode.Attributes["name"] == null || dNode.Attributes["details"] == null)
                        {
                            continue;
                        }

                        bEnabled = (dNode.Attributes["enabled"] != null ? dNode.Attributes["enabled"].Value : "true") == "true";
                        var filter = dNode.Attributes["filter"] != null ? dNode.Attributes["filter"].Value : string.Empty;

                        group.AddDestination(dNode.Attributes["name"].Value, dNode.Attributes["details"].Value, bEnabled, filter);
                    }
                }

                // let's add the destination binding groups
                XmlNode destinationBindingGroupNodes = gNode.SelectSingleNode("./destinationBindingGroups");
                if (destinationBindingGroupNodes != null)
                {
                    foreach (XmlNode bNode in destinationBindingGroupNodes.ChildNodes)
                    {
                        if (bNode.Name != "destinationBindingGroup")
                        {
                            continue;
                        }

                        var bindingGroupName = bNode.Attributes["name"] != null ? bNode.Attributes["name"].Value : null;
                        var bindingGroup     = group.GetDestinationBindingGroup(bindingGroupName);
                        if (bindingGroup == null)
                        {
                            bindingGroup = group.AddDestinationBindingGroup(bindingGroupName);
                        }
                        else
                        {
                            bindingGroup.ClearDestinationBindings();
                        }

                        foreach (XmlNode dbNode in bNode.ChildNodes)
                        {
                            if (dbNode.Name != "destination")
                            {
                                continue;
                            }

                            if (dbNode.Attributes["name"] == null)
                            {
                                continue;
                            }

                            bindingGroup.AddDestinationBinding(dbNode.Attributes["name"].Value);
                        }
                    }
                }
            }

            return(groups);
        }