view Agendas/trunk/src/Agendas.Web/CustomModelMetadataProvider/ResolverThroughResource.cs @ 148:c99636fbdc5f

Ticket 155: Agregar Nro de Orden, Tipo y Duración real en la pantalla de Histórico, similar a como es la página actual en altnethispano.org. Pendiente: Falta que tome la duración cargada.
author juanjose.montesdeocaarbos
date Tue, 02 Aug 2011 23:05:50 -0300
parents ee4e699e4551
children
line wrap: on
line source

using System;

namespace AltNetHispano.Agendas.Web.CustomModelMetadataProvider
{
	public class ResolverThroughResource<T> : IResolverByConvention
	{
		public string GetDisplayName(string propertyName)
		{
			return SearchResource(propertyName);
		}

		public string GetDescription(string propertyName)
		{
			return SearchResource(propertyName + "Description");
		}

		public Type ResourceType
		{
			get { return typeof(T); }
		}

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

	}
}