view Agendas/trunk/src/Agendas.Web/EditorDefaultExtensions.cs @ 298:9bc60d166c8a

Se corrigieron los tests por el cambio de Patrocinador, para que no persista el logo en disco. Se comentó el código de PatrocinadorApiController, que no se utiliza.
author juanjose.montesdeocaarbos
date Sun, 19 Feb 2012 16:00:38 -0300
parents 23aaf98b8377
children
line wrap: on
line source

using System.Web;
using System.Web.Mvc;

namespace AltNetHispano.Agendas.Web
{
    public static class EditorDefaultExtensions
    {
        public static HtmlString GetTitleForModel<T>(this HtmlHelper<T> helper)
        {
            return new HtmlString(SearchResource(helper.ViewData.Model.GetType().Name + "Title"));
        }

        public static HtmlString GetDescriptionForModel<T>(this HtmlHelper<T> helper)
        {
            return new HtmlString(SearchResource(helper.ViewData.Model.GetType().Name + "Description"));
        }

        public static HtmlString GetLegendForModel<T>(this HtmlHelper<T> helper)
        {
            return new HtmlString(SearchResource(helper.ViewData.Model.GetType().Name + "Legend"));
        }

        private static string SearchResource(string resourceName)
        {
            string displayName = null;
            var resourceType = typeof(Resources.Properties.LayoutResources);
            var prop = resourceType.GetProperty(resourceName);
            if (prop != null)
            {
                var value = prop.GetValue(resourceType, null);
                displayName = value != null ? value.ToString() : resourceName;
            }
            return displayName ?? string.Empty;
        }
    }
}