private string GetSignature(MethodBase method) { ParameterInfo[] parameters = method.GetParameters(); StringBuilder builder = new StringBuilder(); builder.Append(method.Name); builder.Append("("); for (int i = 0; i < parameters.Length; i++) { if (i != 0) { builder.Append(","); } ParameterInfo parameter = parameters[i]; Type type = parameter.ParameterType; builder.Append(DiagramHelper.GetTypeName(type)); } builder.Append(")"); return(builder.ToString()); }
public sealed override void OnEntry(MethodExecutionArgs eventArgs) { if (DiagramHelper.Debug && !isExcluded) { bool isConstructorChain = false; bool isNew; object _object = eventArgs.Instance == null ? objectType : eventArgs.Instance; var callee = GetMethodState(_object, out isNew); if (!callee.Debug) { return; } callCount++; if (callee.Trace) { callee.CallCounter++; if (callee.CallCounter > 10) { callee.Trace = false; } } callee.IsAsync = isAsyncSender; if (!isNew && isConstructor) { isConstructorChain = true; } if (Stack.Count > 0 && callee.Equals(Stack.Peek())) { Stack.Push(callee); return; } MethodState caller; if (Stack.Count > 0) { caller = Stack.Peek(); if (verifyStack) { MethodBase callingMethod = new StackFrame(3).GetMethod(); string callerType = DiagramHelper.GetTypeName(callingMethod.DeclaringType); if (caller.InstanceX.Name.StartsWith(callerType)) { callee.Logger.Trace("-- Matches Type--"); } else { callee.Logger.Error("ERROR: stack instance, " + caller.InstanceX.Name + " mismatches type, " + callerType + "." + "\n" + Environment.StackTrace); } } } else { MethodBase callingMethod = new StackFrame(3).GetMethod(); bool otherNew; caller = GetMethodState(callingMethod.DeclaringType, out otherNew); Stack.Push(caller); } if (isAsyncReceiver) { AsyncHandler async = eventArgs.Instance as AsyncHandler; if (async == null) { throw new ApplicationException("The method " + method.Name + " has the Asynchronous attribute applied but the class " + objectType + " does not implement the " + typeof(AsyncHandler).Name + " interface."); } bool otherNew; callee = GetMethodState(async.Instance, out otherNew); if (callCount > 10) { callee.Trace = false; } if (callee.IsEvent) { AsyncEvent(caller, callee, eventArgs.Arguments); } else { AsyncSend(caller, callee, isConstructorChain); } } else if (isAsyncSender) { callee.IsAsync = true; } else if (!isSilent && !caller.IsAsync) { if (callee.IsEvent) { CallEvent(caller, callee, eventArgs.Arguments); } else { Call(caller, callee, isConstructorChain); } } Stack.Push(callee); } }