Esempio n. 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);
        }
Esempio n. 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()));
            }
        }
Esempio n. 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);
            }
        }
Esempio n. 4
0
 public void RegisterRenderer <TComponent>(IComponentRenderer <TRendererContext, TComponent> renderer) where TComponent : IComponent
 {
     _renderers[typeof(TComponent)] = (ctx, c) => renderer.Render(ctx, (TComponent)c, Render);
 }
Esempio n. 5
0
 private void Render(double interpolation)
 {
     _currentAppStateRenderer.Render(interpolation);
 }