/// <summary>
        /// Writes an exception's HTML
        /// </summary>
        /// <param name="builder">The <see cref="StringBuilder"/> to write into</param>
        /// <param name="e">The exception</param>
        /// <param name="severity">The severity of the error</param>
        /// <param name="title">The title of the error</param>
        /// <param name="message">The programmer's message, or null if one wasn't specified</param>
        /// <param name="extraErrorDetails">
        /// A collection of extra details about the error where the key in the <see cref="KeyValuePair{TKey,TValue}"/>
        /// is the detail's name (ie Current Page) and the value is the object that is the detail (ie a string
        /// with the page URL).
        /// </param>
        private void WriteException(StringBuilder builder, Exception e, ErrorSeverity?severity, string title, string message, IEnumerable <KeyValuePair <string, object> > extraErrorDetails)
        {
            ErrorTableRenderer.RenderTableStart(builder);
            ErrorTableRenderer.RenderTableHeading(builder, b => b.Append(HttpUtility.HtmlEncode(title)));
            ErrorTableRenderer.RenderKeyValueRow(builder, b => b.Append("Object Type"), b => b.Append(e.GetType().FullName));

            RenderDetails(builder, UtilityMethods.GetDetailsForObject(e, DetailProviders, FallbackDetailProvider));

            if (severity != null)
            {
                ErrorTableRenderer.RenderKeyValueRow(builder, b => b.Append("Severity"), b => b.Append(severity.ToString()));
            }
            if (message != null)
            {
                ErrorTableRenderer.RenderKeyValueRow(builder, b => b.Append("Programmer Message"), b => b.Append(HttpUtility.HtmlEncode(message)));
            }
            if (e.InnerException != null)
            {
                ErrorTableRenderer.RenderKeyValueRow(builder, b => b.Append("Inner Exception"), b => WriteException(b, e.InnerException, null, "Inner Exception", null, new KeyValuePair <string, object> [0]));
            }

            RenderDetails(builder, extraErrorDetails);

            ErrorTableRenderer.RenderKeyValueMultiRow(builder, b => b.Append("Stack Trace"), b => b.Append("<pre>" + e.StackTrace + "</pre>"));
            ErrorTableRenderer.RenderTableEnd(builder);
        }
        /// <summary>
        /// Renders the detail object to a <see cref="StringBuilder"/>
        /// </summary>
        /// <param name="context">The rendering context</param>
        protected override void DoRender(RenderContext <NameValueCollection> context)
        {
            ErrorTableRenderer.RenderTableStart(context.Builder);
            ErrorTableRenderer.RenderTableKeyValueHeading(context.Builder, b => b.Append("Key"), b => b.Append("Value"));

            foreach (string key in context.ObjectToRender.AllKeys)
            {
                ITypeRenderer keyRenderer   = UtilityMethods.ChooseTypeRenderer(key, context.TypeRenderers);
                ITypeRenderer valueRenderer = UtilityMethods.ChooseTypeRenderer(context.ObjectToRender[key], context.TypeRenderers);

                ErrorTableRenderer.RenderKeyValueRow(context.Builder, b => keyRenderer.Render(context.Copy((object)key, b)), b => valueRenderer.Render(context.Copy((object)context.ObjectToRender[key], b)));
            }

            ErrorTableRenderer.RenderTableEnd(context.Builder);
        }
        /// <summary>
        /// Renders the detail object to a <see cref="StringBuilder"/>
        /// </summary>
        /// <param name="context">The rendering context</param>
        protected override void DoRender(RenderContext <IDictionary> context)
        {
            ErrorTableRenderer.RenderTableStart(context.Builder);
            ErrorTableRenderer.RenderTableKeyValueHeading(context.Builder, b => b.Append("Key"), b => b.Append("Value"));

            foreach (DictionaryEntry entry in context.ObjectToRender)
            {
                ITypeRenderer keyRenderer   = UtilityMethods.ChooseTypeRenderer(entry.Key, context.TypeRenderers);
                ITypeRenderer valueRenderer = UtilityMethods.ChooseTypeRenderer(entry.Value, context.TypeRenderers);

                ErrorTableRenderer.RenderKeyValueRow(context.Builder, b => keyRenderer.Render(context.Copy(entry.Key, b)), b => valueRenderer.Render(context.Copy(entry.Value, b)));
            }

            ErrorTableRenderer.RenderTableEnd(context.Builder);
        }
        /// <summary>
        /// Renders the detail object to a <see cref="StringBuilder"/>
        /// </summary>
        /// <param name="context">The rendering context</param>
        protected override void DoRender(RenderContext <object> context)
        {
            ErrorTableRenderer.RenderTableStart(context.Builder);
            ErrorTableRenderer.RenderKeyValueRow(context.Builder, b => b.Append("Object Type"), b => b.Append(context.ObjectToRender.GetType().FullName));

            IEnumerable <KeyValuePair <string, object> > details = UtilityMethods.GetDetailsForObject(context.ObjectToRender, context.DetailProviders, context.FallbackDetailProvider);

            foreach (KeyValuePair <string, object> detailPair in details)
            {
                ITypeRenderer keyRenderer   = UtilityMethods.ChooseTypeRenderer(detailPair.Key, context.TypeRenderers);
                ITypeRenderer valueRenderer = UtilityMethods.ChooseTypeRenderer(detailPair.Value, context.TypeRenderers);
                ErrorTableRenderer.RenderKeyValueRow(context.Builder, b => keyRenderer.Render(context.Copy <object>(detailPair.Key, b)), b => valueRenderer.Render(context.Copy(detailPair.Value, b)));
            }

            ErrorTableRenderer.RenderTableEnd(context.Builder);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Renders the detail object to a <see cref="StringBuilder"/>
        /// </summary>
        /// <param name="context">The rendering context</param>
        protected override void DoRender(RenderContext <IEnumerable> context)
        {
            ErrorTableRenderer.RenderTableStart(context.Builder);
            ErrorTableRenderer.RenderTableKeyValueHeading(context.Builder, b => b.Append("Index"), b => b.Append("Value"));

            int i = 0;

            foreach (object obj in context.ObjectToRender)
            {
                ITypeRenderer objRenderer = UtilityMethods.ChooseTypeRenderer(obj, context.TypeRenderers);

                ErrorTableRenderer.RenderKeyValueRow(context.Builder, b => b.Append(i), b => objRenderer.Render(context.Copy(obj, b)));
                i++;
            }

            ErrorTableRenderer.RenderTableEnd(context.Builder);
        }
        /// <summary>
        /// Writes an error's HTML
        /// </summary>
        /// <param name="builder">The <see cref="StringBuilder"/> to write into</param>
        /// <param name="errorObject"></param>
        /// <param name="severity">The severity of the error</param>
        /// <param name="title">The title of the error</param>
        /// <param name="message">The programmer's message, or null if one wasn't specified</param>
        /// <param name="extraErrorDetails">
        /// A collection of extra details about the error where the key in the <see cref="KeyValuePair{TKey,TValue}"/>
        /// is the detail's name (ie Current Page) and the value is the object that is the detail (ie a string
        /// with the page URL).
        /// </param>
        private void WriteError(StringBuilder builder, object errorObject, ErrorSeverity severity, string title, string message, IEnumerable <KeyValuePair <string, object> > extraErrorDetails)
        {
            ErrorTableRenderer.RenderTableStart(builder);
            ErrorTableRenderer.RenderTableHeading(builder, b => b.Append(HttpUtility.HtmlEncode(title)));
            ErrorTableRenderer.RenderKeyValueRow(builder, b => b.Append("Object Type"), b => b.Append(errorObject.GetType().FullName));

            RenderDetails(builder, UtilityMethods.GetDetailsForObject(errorObject, DetailProviders, FallbackDetailProvider));

            ErrorTableRenderer.RenderKeyValueRow(builder, b => b.Append("Severity"), b => b.Append(severity.ToString()));
            if (message != null)
            {
                ErrorTableRenderer.RenderKeyValueRow(builder, b => b.Append("Programmer Message"), b => b.Append(HttpUtility.HtmlEncode(message)));
            }

            RenderDetails(builder, extraErrorDetails);

            ErrorTableRenderer.RenderTableEnd(builder);
        }