Go to the documentation of this file.00001 using System;
00002 using System.Collections.Generic;
00003 using System.Linq;
00004 using System.Text;
00005 using System.Web.Mvc;
00006
00007 namespace N2.Web.Mvc.Html
00008 {
00009 internal static class ContextExtensions
00010 {
00011 internal static HtmlHelper<TItem> CreateContentItemHelper<TItem>(this ViewContext viewContext)
00012 where TItem : ContentItem
00013 {
00014 var contentDictionary = new ViewDataDictionary<TItem>(viewContext.CurrentItem<TItem>());
00015 var controllerContext = viewContext.Controller.ControllerContext;
00016 var contentContext = new ViewContext(controllerContext, viewContext.View, contentDictionary, viewContext.TempData, viewContext.HttpContext.Response.Output);
00017 var content = new HtmlHelper<TItem>(contentContext, new ItemViewDataContainer { ViewData = contentDictionary });
00018 return content;
00019 }
00020
00021 class ItemViewDataContainer : IViewDataContainer
00022 {
00023 public ViewDataDictionary ViewData { get; set; }
00024 }
00025 }
00026 }