Exemplo n.º 1
0
        protected virtual void AddTo(IEnumerable <Component> fragments, Control container, IArticle article, IDictionary <string, object> state)
        {
            var list = fragments.ToList();

            for (int i = 0; i < list.Count; i++)
            {
                var f   = list[i];
                var ctx = new ViewContext {
                    Renderer = this, Article = article, Fragment = f, State = state
                };
                if (i > 0)
                {
                    ctx.Previous = list[i - 1];
                }
                if (i < list.Count - 1)
                {
                    ctx.Next = list[i + 1];
                }

                if (Renderers.ContainsKey(f.Command))
                {
                    Control c = Renderers[f.Command].AddTo(container, ctx);
                }
                else if (FallbackRenderer != null)
                {
                    FallbackRenderer.AddTo(container, ctx);
                }
            }
        }
Exemplo n.º 2
0
 protected virtual void AddTo(IEnumerable <Fragment> fragments, Control container, ContentItem article, IDictionary <string, object> state)
 {
     foreach (Fragment f in fragments)
     {
         var ctx = new ViewContext {
             Article = article as IArticle, Fragment = f, State = state
         };
         if (Renderers.ContainsKey(f.Name))
         {
             Control c = Renderers[f.Name].AddTo(container, ctx);
             if (f.ChildFragments != null)
             {
                 AddTo(f.ChildFragments, c, article, state);
             }
         }
         else if (FallbackRenderer != null)
         {
             FallbackRenderer.AddTo(container, ctx);
         }
     }
 }
Exemplo n.º 3
0
        public string Render(ScriptBundle unusedParameter)
        {
            if (isDebuggingEnabled && Assets.Any())
            {
                return(FallbackRenderer.Render(this));
            }

            var conditionalRenderer = new ConditionalRenderer();

            return(conditionalRenderer.Render(Condition, html =>
            {
                if (Assets.Any())
                {
                    RenderScriptHtmlWithFallback(html);
                }
                else
                {
                    RenderScriptHtml(html);
                }
            }));
        }
Exemplo n.º 4
0
        string CreateFallbackScripts()
        {
            var scripts = FallbackRenderer.Render(this);

            return(ConvertToDocumentWriteCalls(scripts));
        }