コード例 #1
0
        static public IReflectInsight Add(String name, IReflectInsight ri)
        {
            lock (FInstances)
            {
                RILogManagerNode node = GetNode(name);
                if (node != null)
                {
                    // if the RI already exists, only change the category, color, enabled state and destination binding groups
                    lock (node.Instance)
                    {
                        node.Instance.ClearDestinationBindingGroup();
                        node.Instance.Category  = ri.Category;
                        node.Instance.BackColor = ri.BackColor;
                        node.Instance.Enabled   = ri.Enabled;
                        node.Instance.DestinationBindingGroupId = ri.DestinationBindingGroupId;
                    }

                    ri.Dispose();
                    return(node.Instance);
                }

                FInstances[name] = new RILogManagerNode(name, ri);
                return(ri);
            }
        }
コード例 #2
0
        static public IReflectInsight Add(RIInstance instance)
        {
            lock (FInstances)
            {
                // this method checks to see if the RI already exists
                // and only updates the category, bkColor and destination binding values.
                // if it doesn't exist then it creates a new RI and adds it to the list
                RILogManagerNode node = GetNode(instance.Name);
                if (node != null)
                {
                    // if the RI already exists, only change the category, color and destination binding groups
                    lock (node.Instance)
                    {
                        node.Instance.ClearDestinationBindingGroup();
                        node.Instance.Category  = instance.Category;
                        node.Instance.BackColor = RIPastelBackColor.GetColorByName(instance.BkColor);
                        node.Instance.SetDestinationBindingGroup(instance.DestinationBindingGroup);
                    }

                    return(node.Instance);
                }

                // create a new instance and add it
                return(Add(instance.Name, CreateInstance(instance)));
            }
        }
コード例 #3
0
        static private void FreeInstances()
        {
            if (FInstances != null)
            {
                foreach (RILogManagerNode node in FInstances.Values)
                {
                    node.Dispose();
                }

                FInstances = null;
                FDefault   = null;
            }
        }
コード例 #4
0
        static public void SetDefault(String name)
        {
            lock (FInstances)
            {
                RILogManagerNode node = (RILogManagerNode)FInstances[name];
                if (node == null)
                {
                    return;
                }

                FDefault = node;
            }
        }
コード例 #5
0
        static private void EstablishDefault()
        {
            lock (FInstances)
            {
                String           defaultRi = ReflectInsightConfig.Settings.GetLogManagerAttribute("default", "default");
                RILogManagerNode node      = GetNode(defaultRi);

                if (node == null)
                {
                    Add(defaultRi, new ReflectInsight(defaultRi));
                    node = GetNode(defaultRi);
                }

                FDefault = node;
            }
        }
コード例 #6
0
        static public IReflectInsight Get(String name)
        {
            lock (FInstances)
            {
                if (string.IsNullOrWhiteSpace(name))
                {
                    return(FDefault.Instance);
                }

                RILogManagerNode node = (RILogManagerNode)FInstances[name];
                if (node != null)
                {
                    return(node.Instance);
                }

                return(Add(name, name));
            }
        }
コード例 #7
0
        static public Boolean Remove(String name, Boolean bDispose)
        {
            lock (FInstances)
            {
                RILogManagerNode node = GetNode(name);
                if (node == null)
                {
                    return(false);
                }

                if (bDispose)
                {
                    node.Dispose();
                }

                FInstances.Remove(name);
                EstablishDefault();

                return(true);
            }
        }