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); } }
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))); } }
static private void FreeInstances() { if (FInstances != null) { foreach (RILogManagerNode node in FInstances.Values) { node.Dispose(); } FInstances = null; FDefault = null; } }
static public void SetDefault(String name) { lock (FInstances) { RILogManagerNode node = (RILogManagerNode)FInstances[name]; if (node == null) { return; } FDefault = node; } }
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; } }
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)); } }
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); } }