Go to the documentation of this file.00001 using System;
00002 using System.Linq.Expressions;
00003 using N2.Web.UI;
00004 using System.Web.Mvc;
00005
00006 namespace N2.Web.Mvc.Html
00007 {
00008 public static class DisplayExtensions
00009 {
00010 public static Displayable DisplayContent(this HtmlHelper helper, string detailName)
00011 {
00012 return helper.DisplayContent(helper.CurrentItem(), detailName);
00013 }
00014
00015 public static Displayable DisplayContent(this HtmlHelper helper, ContentItem item, string detailName)
00016 {
00017 return new Displayable(helper, detailName, item);
00018 }
00019
00020
00021
00022 public static Displayable DisplayContent<TItem>(this HtmlHelper<TItem> helper,
00023 Expression<Func<TItem, object>> expression)
00024 where TItem : ContentItem
00025 {
00026 var member = (MemberExpression) expression.Body;
00027 return helper.DisplayContent(member.Member.Name);
00028 }
00029
00030 public static Displayable DisplayContent<TItem>(this HtmlHelper helper, TItem item, Expression<Func<TItem, object>> expression)
00031 where TItem : ContentItem
00032 {
00033 var member = (MemberExpression) expression.Body;
00034 return helper.DisplayContent(item, member.Member.Name);
00035 }
00036
00037
00038
00039 public static void RenderDisplay(this HtmlHelper helper, string detailName)
00040 {
00041 helper.RenderDisplay(helper.CurrentItem(), detailName);
00042 }
00043
00044 public static void RenderDisplay(this HtmlHelper helper, ContentItem item, string detailName)
00045 {
00046 new Displayable(helper, detailName, item)
00047 .Render(helper);
00048 }
00049
00050
00051
00052 public static void RenderDisplay<TItem>(this HtmlHelper<TItem> helper,
00053 Expression<Func<TItem, object>> expression)
00054 where TItem : ContentItem
00055 {
00056 var member = (MemberExpression)expression.Body;
00057 helper.RenderDisplay(member.Member.Name);
00058 }
00059
00060 public static void RenderDisplay<TItem>(this HtmlHelper helper, TItem item, Expression<Func<TItem, object>> expression)
00061 where TItem : ContentItem
00062 {
00063 var member = (MemberExpression)expression.Body;
00064 helper.DisplayContent(item, member.Member.Name).Render(helper);
00065 }
00066 }
00067 }