public static void StateChange(object _object, object obj) { if (Debug) { bool isNew; DiagramInstance instance = GetInstance(_object, out isNew); if (instance.Trace) { instance.Logger.Trace(instance.Name + " >>> " + obj); } } }
public static void Line(object _object) { if (Debug) { bool isNew; DiagramInstance instance = GetInstance(_object, out isNew); if (instance.Trace) { MethodBase caller = new StackFrame(1).GetMethod(); instance.Logger.Trace("# " + _object); } } }
public static DiagramInstance GetInstance(object _object, out bool isNew) { DiagramInstance callee; isNew = true; if (!Instances.TryGetValue(new DiagramObject(_object), out callee)) { MethodBase method = new StackFrame(1).GetMethod(); Type type; string typeName; string fullName; if (_object is Type) { type = (Type)_object; typeName = "(" + GetTypeName(type) + ")"; fullName = type.FullName; } else { type = _object.GetType(); typeName = GetTypeName(type); fullName = type.FullName; } if (AppAbbreviation != null) { typeName = AppAbbreviation + ":" + typeName; } callee = new DiagramInstance(typeName, fullName); if (!(_object is Type)) { int counter; lock (locker) { if (!InstanceCounters.TryGetValue(type, out counter)) { counter = 0; InstanceCounters[type] = counter; } InstanceCounters[type] = ++counter; } callee.Name += counter; } Instances[new DiagramObject(_object)] = callee; } else { isNew = false; } return(callee); }