private XElement GetMethodXElement(MethodInformation methodInfo) { return(new XElement( "method", new XAttribute("name", methodInfo.Name), new XAttribute("class", methodInfo.ClassName), new XAttribute("time", methodInfo.ExecutionTime) )); }
private JObject GetMethodJObject(MethodInformation methodInfo) { return(new JObject { { "name", methodInfo.Name }, { "class", methodInfo.ClassName }, { "time", methodInfo.ExecutionTime }, }); }
private XElement GetMethodXElementWithChildMethods(MethodInformation methodInfo) { XElement methodXElement = GetMethodXElement(methodInfo); foreach (MethodInformation method in methodInfo.ChildMethods) { XElement childMethod = GetMethodXElement(method); if (method.ChildMethods.Count > 0) { childMethod = GetMethodXElementWithChildMethods(method); } methodXElement.Add(childMethod); } return(methodXElement); }
private JObject GetMethodJObjectWithChildMethods(MethodInformation methodInfo) { JObject methodJObject = GetMethodJObject(methodInfo); JArray methodsJArray = new JArray(); foreach (MethodInformation method in methodInfo.ChildMethods) { JObject childMethodJObject = GetMethodJObject(method); if (method.ChildMethods.Count > 0) { childMethodJObject = GetMethodJObjectWithChildMethods(method); } methodsJArray.Add(childMethodJObject); } methodJObject.Add("methods", methodsJArray); return(methodJObject); }
public void StopTrace() { _currentMethodTracer.StopTrace(); StackTrace stackTrace = new StackTrace(); MethodBase method = stackTrace.GetFrame(2).GetMethod(); string methodName = method.Name; string className = method.ReflectedType.Name; double methodExecutionTime = _currentMethodTracer.GetExecutionTime(); List <MethodInformation> methodInfos = _currentMethodTracer.GetChildMethods(); MethodInformation methodInfo = new MethodInformation(methodName, className, methodExecutionTime, methodInfos); if (_methodTracers.Count > 0) { _currentMethodTracer = _methodTracers.Pop(); _currentMethodTracer.AddChildMethod(methodInfo); } else { _methodInfoList.Add(methodInfo); _currentMethodTracer = null; } }
public void AddChildMethod(MethodInformation childMethod) { _childMethods.Add(childMethod); }