示例#1
0
        /// <summary>
        /// Renders the specified <see cref="MvcComponentBase" /> to the current WebForms view.
        /// </summary>
        /// <param name="helper">The HTML helper instance that this method extends.</param>
        /// <param name="component">The <see cref="MvcComponentBase" /> to render.</param>
        public static void KrystalwareWebForms(this HtmlHelper helper, MvcComponentBase component)
        {
            IComponentRenderer renderer = RendererFactory.GetRenderer(component);

            renderer.Register(component);

            using (HtmlTextWriter w = new HtmlTextWriter(helper.ViewContext.Writer))
                renderer.Render(component, w);
        }
示例#2
0
        /// <summary>
        /// Renders the specified <see cref="MvcComponentBase" /> and returns the output for a Razor view.
        /// </summary>
        /// <param name="helper">The HTML helper instance that this method extends.</param>
        /// <param name="component">The <see cref="MvcComponentBase" /> to render.</param>
        public static MvcHtmlString KrystalwareRazor(this HtmlHelper helper, MvcComponentBase component)
        {
            IComponentRenderer renderer = RendererFactory.GetRenderer(component);

            renderer.Register(component);

            using (StringWriter s = new StringWriter())
            {
                using (HtmlTextWriter w = new HtmlTextWriter(s))
                    renderer.Render(component, w);

                return(MvcHtmlString.Create(s.ToString()));
            }
        }
示例#3
0
        protected void Render(TRendererContext ctx, IComponent component)
        {
            if (component.Layout.Size.Width * component.Layout.Size.Height == 0)
            {
                return;
            }

            if (_renderers.TryGetValue(component.GetType(), out var render))
            {
                render(ctx, component);
            }
            else
            {
                DefaultRenderer.Render(ctx, component, Render);
            }
        }
示例#4
0
 public void RegisterRenderer <TComponent>(IComponentRenderer <TRendererContext, TComponent> renderer) where TComponent : IComponent
 {
     _renderers[typeof(TComponent)] = (ctx, c) => renderer.Render(ctx, (TComponent)c, Render);
 }
示例#5
0
 private void Render(double interpolation)
 {
     _currentAppStateRenderer.Render(interpolation);
 }