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); } } }
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); } } }