Exemplo n.º 1
0
        // Private

        private void UpdateThreadTime(TraceTree node)
        {
            if (node == null)
            {
                throw new ArgumentNullException(nameof(node));
            }

            if (CallStack.Count == 0)
            {
                Time += node.Info.Time;
            }
        }
Exemplo n.º 2
0
 public void PushNode(TraceTree node)
 {
     if (CallStack.Count == 0)
     {
         CallTree.Add(node);
     }
     else
     {
         CallStack.Peek().Children.Add(node);
     }
     CallStack.Push(node);
     node.StartTimer();
 }
Exemplo n.º 3
0
        public TraceTree PopNode()
        {
            if (CallStack.Count <= 0)
            {
                throw new Exception(ExceptionMessages.CantPopExceptionMessage);
            }
            TraceTree result = CallStack.Pop();

            result.StopTimer();
            UpdateThreadTime(result);

            return(result);
        }
Exemplo n.º 4
0
        public void StartTrace()
        {
            StackTrace context = new StackTrace(ConfigConstants.NeedFileInfoFlag);

            MethodBase currentMethod     = context.GetFrame(ConfigConstants.SkipFramesCount).GetMethod();
            MethodInfo currentMethodInfo = new MethodInfo(currentMethod);

            int threadId = Thread.CurrentThread.ManagedThreadId;

            lock (LockObj)
            {
                if (_threadsDictionary.ContainsKey(threadId) == false)
                {
                    _threadsDictionary.Add(threadId, new ThreadsListItem(threadId));
                }

                TraceTree node = new TraceTree(currentMethodInfo);
                _threadsDictionary[threadId].PushNode(node);
            }
        }