Esempio n. 1
0
        static private void AddDefaultListenerGroupIfNecessary()
        {
            lock (FListenerGroups)
            {
                String defaultName = FDefaultGroup != null ? FDefaultGroup.Name : "_default";

                ListenerGroup group = (ListenerGroup)FListenerGroups[defaultName];
                if (group == null)
                {
                    // default group doesn't exist, add it
                    FDefaultGroup = new ListenerGroup("_default", true, false);
                    FDefaultGroup.AddDestination("_default", "Console");
                    AddGroup(FDefaultGroup, true);
                }
            }
        }
        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);
        }