Example #1
0
        private StackTraceItem _getCallStackInfo()
        {
            StackTraceItem result = new StackTraceItem();

            if (this._dumpCallStackInfo)
            {
                result = Completers.StackTrace.CompleteCallerPoint();
            }
            return(result);
        }
Example #2
0
        /// <summary>
        /// Display value in browser console by <c>console.[log|info|debug|trace|warn|error|table](obj);</c> call.
        /// </summary>
        /// <param name="obj">Any value to serialize with <c>(new JavascriptSerializer()).Serialize(obj);</c> and to display in client browser console.</param>
        /// <param name="dumpType">Javascript browser console object function name to call on client, but in upper case.</param>
        /// <returns>FireDump instance is returned to call any other FireDump method in call chain.</returns>
        public FireDump Dump(object obj, FireDumpType dumpType = FireDumpType.Debug)
        {
            if (!this._enabled)
            {
                return(this);
            }
            StackTraceItem callPoint = Completers.StackTrace.CompleteCallerPoint();

            return(this._renderHeaders(new FireDumpItem {
                Type = dumpType,
                File = callPoint.File.ToString(),
                Line = callPoint.Line,
                Content = obj
            }));
        }
Example #3
0
        /// <summary>
        /// Display value in browser console by <c>console.table(obj);</c> call.
        /// This console item is rendered as table with variable count of columns and rows - it depends by value.
        /// </summary>
        /// <param name="label">Table heading text.</param>
        /// <param name="obj">
        /// Any structuralized value to serialize with <c>(new JavascriptSerializer()).Serialize(obj);</c> and to display in client browser console.
        /// Basicly it shoud by .NET Array with Arrays, but it should by any .NET IList, ICollection, IEnumerable, IDictionary, anything for foreach or for cycle in two levels.
        /// </param>
        /// <returns>FireDump instance is returned to call any other FireDump method in call chain.</returns>
        public FireDump Table(string label, object obj)
        {
            if (!this._enabled)
            {
                return(this);
            }
            StackTraceItem callPoint = this._getCallStackInfo();

            return(this._renderHeaders(new FireDumpItem {
                Type = FireDumpType.Table,
                Content = obj,
                File = callPoint.File.ToString(),
                Line = callPoint.Line,
                Label = label
            }));
        }
Example #4
0
        /// <summary>
        /// Display .NET Exception in browser console by <c>console.error(obj);</c> call.
        /// This console item is rendered as red text with light red background and with red icon with cross inside.
        /// </summary>
        /// <param name="exception">.NET Exception to display in client browser console.</param>
        /// <returns>FireDump instance is returned to call any other FireDump method in call chain.</returns>
        public FireDump Exception(Exception exception)
        {
            if (!this._enabled)
            {
                return(this);
            }
            StackTraceItem callPoint = this._getCallStackInfo();
            StackTraceItem?exceptionThrowPoint;
            Dictionary <string, ExceptionToRender> exceptions = Completers.StackTrace.CompleteInnerExceptions(exception, true);
            int       i = 0;
            Exception e;
            string    content;

            foreach (var item in exceptions)
            {
                e       = item.Value.Exception;
                content = $"{e.GetType().FullName}: {e.Message}";
                RenderingCollection preparedResult = Completers.StackTrace.RenderStackTraceForException(
                    item.Value, false, false, i++
                    );
                exceptionThrowPoint = null;
                foreach (StackTraceItem stackTracesItem in preparedResult.AllStackTraces)
                {
                    if (stackTracesItem.File.ToString().Length > 0)
                    {
                        exceptionThrowPoint = new StackTraceItem {
                            File = stackTracesItem.File.ToString(),
                            Line = stackTracesItem.Line
                        };
                        break;
                    }
                }
                if (exceptionThrowPoint == null)
                {
                    exceptionThrowPoint = callPoint;
                }
                this._renderHeaders(new FireDumpItem {
                    Type    = FireDumpType.Error,
                    Content = content,
                    File    = exceptionThrowPoint.Value.File.ToString(),
                    Line    = exceptionThrowPoint.Value.Line
                });
            }
            return(this);
        }