Permalink
Browse files

convenience method on IProjectionRunner, another for IFubuPage.LabelT…

…ext(), and removed a warning from EnumerableProjection
  • Loading branch information...
1 parent 6127744 commit 00886894ad08f4a56ccbc2fe0fdef93ff6d8205e @jeremydmiller jeremydmiller committed Dec 19, 2011
@@ -14,7 +14,7 @@ public class EnumerableProjection<TParent, TChild> : IProjection<TParent>
public string NodeName;
public string LeafName = typeof(TChild).Name;
- public static EnumerableProjection<TParent, TChild> For<TParent, TChild>(Expression<Func<TParent, IEnumerable<TChild>>> expression)
+ public static EnumerableProjection<TParent, TChild> For(Expression<Func<TParent, IEnumerable<TChild>>> expression)
{
var accessor = ReflectionHelper.GetAccessor(expression);
@@ -54,6 +54,7 @@ public interface IProjectionRunner<T>
IDictionary<string, object> ProjectToJson(IProjection<T> projection, IValues<T> values);
IDictionary<string, object> ProjectToJson<TProjection>(IValues<T> values) where TProjection : IProjection<T>;
+ IDictionary<string, object> ProjectToJson<TProjection>(T subject) where TProjection : IProjection<T>;
}
public class ProjectionRunner<T> : IProjectionRunner<T>
@@ -94,6 +95,11 @@ public void Run(IProjection<T> projection, IValues<T> values, IMediaNode node)
{
return DictionaryMediaNode.Write(node => Run<TProjection>(values, node));
}
+
+ public IDictionary<string, object> ProjectToJson<TProjection>(T subject) where TProjection : IProjection<T>
+ {
+ return ProjectToJson<TProjection>(new SimpleValues<T>(subject));
+ }
}
}
@@ -2,6 +2,7 @@
using System.Linq.Expressions;
using FubuCore;
using FubuCore.Reflection;
+using FubuLocalization;
using FubuMVC.Core.Assets.Files;
using FubuMVC.Core.Assets.Http;
using FubuMVC.Core.Http;
@@ -18,6 +19,18 @@ namespace FubuMVC.Core.UI
{
public static class FubuPageExtensions
{
+ /// <summary>
+ /// Just returns the localized header text for a property of the view model
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="page"></param>
+ /// <param name="expression"></param>
+ /// <returns></returns>
+ public static string HeaderText<T>(this IFubuPage<T> page, Expression<Func<T, object>> expression) where T : class
+ {
+ return LocalizationManager.GetHeader(expression);
+ }
+
public static ITagGenerator<T> Tags<T>(this IFubuPage<T> page) where T : class
{
var generator = page.Get<ITagGenerator<T>>();

0 comments on commit 0088689

Please sign in to comment.