Go to the documentation of this file.00001 using System;
00002 using N2.Engine;
00003 using N2.Web.Parts;
00004 using N2.Web.UI;
00005 using System.Web.Mvc;
00006
00007 namespace N2.Web.Mvc.Html
00008 {
00009 public abstract class ItemHelper
00010 {
00011 PartsAdapter partsAdapter;
00012 MvcAdapter mvcAdapter;
00013 ContentItem currentItem;
00014
00015 protected ItemHelper(HtmlHelper helper, ContentItem currentItem)
00016 {
00017 Html = helper;
00018 CurrentItem = currentItem;
00019 }
00020
00021 protected HtmlHelper Html { get; set; }
00022
00023 protected ContentItem CurrentItem
00024 {
00025 get { return currentItem ?? (currentItem = Html.CurrentItem()); }
00026 set { this.currentItem = value; }
00027 }
00028
00030 protected virtual PartsAdapter PartsAdapter
00031 {
00032 get
00033 {
00034 if (partsAdapter == null)
00035 partsAdapter = Adapters.ResolveAdapter<PartsAdapter>(CurrentItem);
00036 return partsAdapter;
00037 }
00038 }
00039
00041 protected virtual MvcAdapter MvcAdapter
00042 {
00043 get
00044 {
00045 if (mvcAdapter == null)
00046 mvcAdapter = Adapters.ResolveAdapter<MvcAdapter>(CurrentItem);
00047 return mvcAdapter;
00048 }
00049 }
00050
00051 [Obsolete]
00052 protected virtual MvcAdapter GetMvcAdapterFor(Type contentType)
00053 {
00054 return Adapters.ResolveAdapter<MvcAdapter>(contentType);
00055 }
00056
00057 protected IContentAdapterProvider Adapters
00058 {
00059 get { return Html.ResolveService<IContentAdapterProvider>(); }
00060 }
00061 }
00062 }