Mercurial > altnet-hispano
comparison Agendas/trunk/src/Agendas.Web/EditorDefaultExtensions.cs @ 155:23aaf98b8377
Generalizando editores en EditorDefault basando los textos en recursos
author | Nelo@Guinea.neluz.int |
---|---|
date | Wed, 03 Aug 2011 09:38:23 -0300 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
154:2233039ac2eb | 155:23aaf98b8377 |
---|---|
1 using System.Web; | |
2 using System.Web.Mvc; | |
3 | |
4 namespace AltNetHispano.Agendas.Web | |
5 { | |
6 public static class EditorDefaultExtensions | |
7 { | |
8 public static HtmlString GetTitleForModel<T>(this HtmlHelper<T> helper) | |
9 { | |
10 return new HtmlString(SearchResource(helper.ViewData.Model.GetType().Name + "Title")); | |
11 } | |
12 | |
13 public static HtmlString GetDescriptionForModel<T>(this HtmlHelper<T> helper) | |
14 { | |
15 return new HtmlString(SearchResource(helper.ViewData.Model.GetType().Name + "Description")); | |
16 } | |
17 | |
18 public static HtmlString GetLegendForModel<T>(this HtmlHelper<T> helper) | |
19 { | |
20 return new HtmlString(SearchResource(helper.ViewData.Model.GetType().Name + "Legend")); | |
21 } | |
22 | |
23 private static string SearchResource(string resourceName) | |
24 { | |
25 string displayName = null; | |
26 var resourceType = typeof(Resources.Properties.LayoutResources); | |
27 var prop = resourceType.GetProperty(resourceName); | |
28 if (prop != null) | |
29 { | |
30 var value = prop.GetValue(resourceType, null); | |
31 displayName = value != null ? value.ToString() : resourceName; | |
32 } | |
33 return displayName ?? string.Empty; | |
34 } | |
35 } | |
36 } |