/// <summary>
        /// Renders a collection of details
        /// </summary>
        /// <param name="builder">The <see cref="StringBuilder"/> to render to</param>
        /// <param name="details">
        /// A collection of 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 RenderDetails(StringBuilder builder, IEnumerable <KeyValuePair <string, object> > details)
        {
            RenderContext <object> baseContext = new RenderContext <object>(null, null, this);

            foreach (KeyValuePair <string, object> detailPair in details)
            {
                ITypeRenderer keyRenderer   = UtilityMethods.ChooseTypeRenderer(detailPair.Key, TypeRenderers);
                ITypeRenderer valueRenderer = UtilityMethods.ChooseTypeRenderer(detailPair.Value, TypeRenderers);
                ErrorTableRenderer.RenderKeyValueRow(builder, b => keyRenderer.Render(baseContext.Copy <object>(detailPair.Key, b)), b => valueRenderer.Render(baseContext.Copy(detailPair.Value, b)));
            }
        }
        /// <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);
        }
Пример #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);
        }