private static object ToPlainObject(SpeedTracerData trace)
        {
            if (trace == null)
            {
                return null;
            }

            var startTime = trace.StartTime.ToUnix() * 1000 + trace.StartTime.Millisecond;
            var endTime = trace.EndTime.ToUnix() * 1000 + trace.EndTime.Millisecond;
            var duration = endTime - startTime;

            return new
            {
                range = new
                {
                    duration = duration,
                    start = startTime,
                    end = endTime + duration
                },
                id = Guid.NewGuid().ToString("n"),
                operation = new
                {
                    sourceCodeLocation = new
                    {
                        className = trace.ClassName,
                        methodName = trace.MethodName,
                        lineNumber = trace.LineNumber
                    },
                    type = "METHOD",
                    label = trace.Section
                },
                children = trace.Children.Select(c => ToPlainObject(c))
            };
        }
        private static object ToPlainObject(SpeedTracerData trace)
        {
            if (trace == null)
            {
                return(null);
            }

            var startTime = trace.StartTime.ToUnix() * 1000 + trace.StartTime.Millisecond;
            var endTime   = trace.EndTime.ToUnix() * 1000 + trace.EndTime.Millisecond;
            var duration  = endTime - startTime;

            return(new
            {
                range = new
                {
                    duration = duration,
                    start = startTime,
                    end = endTime + duration
                },
                id = Guid.NewGuid().ToString("n"),
                operation = new
                {
                    sourceCodeLocation = new
                    {
                        className = trace.ClassName,
                        methodName = trace.MethodName,
                        lineNumber = trace.LineNumber
                    },
                    type = "METHOD",
                    label = trace.Section
                },
                children = trace.Children.Select(c => ToPlainObject(c))
            });
        }
        public void Dispose()
        {
            this.endTime = DateTime.Now;

            if (this.parent != null)
            {
                this.parent.SaveChildData(this.section, this.startTime, this.endTime, childData);

                Current = this.parent;
            }
            else
            {
                var data = new SpeedTracerData {
                    Section = section, StartTime = startTime, EndTime = endTime, Children = childData, ClassName = this.className, MethodName = this.methodName, LineNumber = this.lineNumber
                };

                HttpContext.Current.Application["Trace:" + HttpContext.Current.Items["TraceId"]] = data;
            }
        }
        public void Dispose()
        {
            this.endTime = DateTime.Now;

            if (this.parent != null)
            {
                this.parent.SaveChildData(this.section, this.startTime, this.endTime, childData);

                Current = this.parent;
            }
            else
            {
                var data = new SpeedTracerData { Section = section, StartTime = startTime, EndTime = endTime, Children = childData, ClassName = this.className, MethodName = this.methodName, LineNumber = this.lineNumber };

                HttpContext.Current.Application["Trace:" + HttpContext.Current.Items["TraceId"]] = data;
            }
        }