internal List <CallStackInfoExtended> CalculateSnapshot(List <CallStackInfo> stack)
        {
            Tracer.Verbose("SnapshotService.CalculateSnapshot", "START calculating the snapshot");

            List <CallStackInfoExtended> result = new List <CallStackInfoExtended>();

            try
            {
                IEnumerable <CallStackInfo> mainCall = stack.Where(p => p.CalledByHandle == 0);
                foreach (CallStackInfo item in mainCall)
                {
                    CallStackInfoExtended ex = new CallStackInfoExtended(item);
                    result.Add(ex);
                    CalculateCallStackInfoIternals(result, stack, ex);
                }
            }
            catch (Exception error)
            {
                Tracer.Error("SnapshotService.CalculateSnapshot", error);
            }
            finally
            {
                Tracer.Verbose("SnapshotService.CalculateSnapshot", "END calculating the snapshot");
            }
            return(result);
        }
        internal void CalculateCallStackInfoIternals(List <CallStackInfoExtended> result, List <CallStackInfo> stack, CallStackInfoExtended parent)
        {
            Tracer.Verbose("SnapshotService.CalculateCallStackInfoIternals", "START calculating method times");

            try
            {
                IEnumerable <CallStackInfo> calledBy = stack.Where(p => p.CalledByHandle == parent.MethodHandle);
                if (calledBy != null)
                {
                    //when starting the internal time method is equal to total time
                    parent.InternalTick = parent.TotalTick;

                    foreach (CallStackInfo item in calledBy)
                    {
                        //we remove the time spent in each called methods
                        parent.InternalTick -= item.TotalTick;

                        //we create a extended callstak object based on it
                        CallStackInfoExtended ex = new CallStackInfoExtended(item);
                        result.Add(ex);

                        //recursive call through the call stack
                        CalculateCallStackInfoIternals(result, stack, ex);
                    }
                }
            }
            catch (Exception error)
            {
                Tracer.Error("SnapshotService.CalculateCallStackInfoIternals", error);
            }
            finally
            {
                Tracer.Verbose("SnapshotService.CalculateCallStackInfoIternals", "END calculating method times");
            }
        }
        public CallStackInfoAgregated(CallStackInfoExtended item) : base(item)
        {
            TotalTick      = item.TotalTick;
            CalledByHandle = item.CalledByHandle;
            MethodHandle   = item.MethodHandle;
            Namespace      = item.Namespace;

            MethodName   = item.MethodName;
            InternalTick = item.InternalTick;
            CalledBy     = item.CalledBy;
        }