Mercurial > altnet-hispano
changeset 85:8a4135f019dd
cambio de nombre de una clase
author | nelopauselli |
---|---|
date | Wed, 25 May 2011 01:20:24 -0300 |
parents | ee4e699e4551 |
children | 723aed93a0e6 |
files | Agendas/trunk/src/Agendas.Web/Agendas.Web.csproj Agendas/trunk/src/Agendas.Web/CustomModelMetadataProvider/DataAnnotationAndConventionModelMetadataProvider.cs Agendas/trunk/src/Agendas.Web/CustomModelMetadataProvider/DataAnnotationAndResolveByConventionModelMetadataProvider.cs Agendas/trunk/src/Agendas.Web/Global.asax.cs |
diffstat | 4 files changed, 58 insertions(+), 58 deletions(-) [+] |
line wrap: on
line diff
--- a/Agendas/trunk/src/Agendas.Web/Agendas.Web.csproj Wed May 25 01:18:29 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Web/Agendas.Web.csproj Wed May 25 01:20:24 2011 -0300 @@ -69,7 +69,7 @@ <DependentUpon>Global.asax</DependentUpon> </Compile> <Compile Include="HttpContextIdentityProvider.cs" /> - <Compile Include="CustomModelMetadataProvider\DataAnnotationAndResolveByConventionModelMetadataProvider.cs" /> + <Compile Include="CustomModelMetadataProvider\DataAnnotationAndConventionModelMetadataProvider.cs" /> <Compile Include="CustomModelMetadataProvider\IResolverByConvention.cs" /> <Compile Include="CustomModelMetadataProvider\ResolverThroughResource.cs" /> <Compile Include="Models\AccountModels.cs" />
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Web/CustomModelMetadataProvider/DataAnnotationAndConventionModelMetadataProvider.cs Wed May 25 01:20:24 2011 -0300 @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Web.Mvc; + +namespace AltNetHispano.Agendas.Web.CustomModelMetadataProvider +{ + public class DataAnnotationAndConventionModelMetadataProvider : DataAnnotationsModelMetadataProvider + { + private readonly IResolverByConvention _resolverByConvention; + private List<Attribute> _attributeList; + + public DataAnnotationAndConventionModelMetadataProvider(IResolverByConvention resolverByConvention) + { + _resolverByConvention = resolverByConvention; + } + + protected override ModelMetadata CreateMetadata(IEnumerable<Attribute> attributes, Type containerType, Func<object> modelAccessor, Type modelType, string propertyName) + { + _attributeList = new List<Attribute>(attributes); + + var modelMetadata = base.CreateMetadata(attributes, containerType, modelAccessor, modelType, propertyName); + + if (propertyName != null) + { + if (string.IsNullOrWhiteSpace(modelMetadata.DisplayName)) + modelMetadata.DisplayName = _resolverByConvention.GetDisplayName(propertyName); + + if (string.IsNullOrWhiteSpace(modelMetadata.Description)) + modelMetadata.Description = _resolverByConvention.GetDescription(propertyName); + + var validators = _attributeList.OfType<ValidationAttribute>(); + foreach (var validator in validators) + { + if (string.IsNullOrWhiteSpace(validator.ErrorMessage) && + string.IsNullOrWhiteSpace(validator.ErrorMessageResourceName)) + { + var resourceName = propertyName + validator.GetType().Name; + if (resourceName.EndsWith("Attribute")) + resourceName = resourceName.Substring(0, resourceName.Length - 9); + var resourceType = validator.ErrorMessageResourceType ?? _resolverByConvention.ResourceType; + var prop = resourceType.GetProperty(resourceName); + if (prop != null) + { + validator.ErrorMessageResourceType = resourceType; + validator.ErrorMessageResourceName = resourceName; + } + } + } + } + + return modelMetadata; + } + } +} \ No newline at end of file
--- a/Agendas/trunk/src/Agendas.Web/CustomModelMetadataProvider/DataAnnotationAndResolveByConventionModelMetadataProvider.cs Wed May 25 01:18:29 2011 -0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Linq; -using System.Web.Mvc; - -namespace AltNetHispano.Agendas.Web.CustomModelMetadataProvider -{ - public class DataAnnotationAndResolveByConventionModelMetadataProvider : DataAnnotationsModelMetadataProvider - { - private readonly IResolverByConvention _resolverByConvention; - private List<Attribute> _attributeList; - - public DataAnnotationAndResolveByConventionModelMetadataProvider(IResolverByConvention resolverByConvention) - { - _resolverByConvention = resolverByConvention; - } - - protected override ModelMetadata CreateMetadata(IEnumerable<Attribute> attributes, Type containerType, Func<object> modelAccessor, Type modelType, string propertyName) - { - _attributeList = new List<Attribute>(attributes); - - var modelMetadata = base.CreateMetadata(attributes, containerType, modelAccessor, modelType, propertyName); - - if (propertyName != null) - { - if (string.IsNullOrWhiteSpace(modelMetadata.DisplayName)) - modelMetadata.DisplayName = _resolverByConvention.GetDisplayName(propertyName); - - if (string.IsNullOrWhiteSpace(modelMetadata.Description)) - modelMetadata.Description = _resolverByConvention.GetDescription(propertyName); - - var validators = _attributeList.OfType<ValidationAttribute>(); - foreach (var validator in validators) - { - if (string.IsNullOrWhiteSpace(validator.ErrorMessage) && - string.IsNullOrWhiteSpace(validator.ErrorMessageResourceName)) - { - var resourceName = propertyName + validator.GetType().Name; - if (resourceName.EndsWith("Attribute")) - resourceName = resourceName.Substring(0, resourceName.Length - 9); - var resourceType = validator.ErrorMessageResourceType ?? _resolverByConvention.ResourceType; - var prop = resourceType.GetProperty(resourceName); - if (prop != null) - { - validator.ErrorMessageResourceType = resourceType; - validator.ErrorMessageResourceName = resourceName; - } - } - } - } - - return modelMetadata; - } - } -} \ No newline at end of file
--- a/Agendas/trunk/src/Agendas.Web/Global.asax.cs Wed May 25 01:18:29 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Web/Global.asax.cs Wed May 25 01:20:24 2011 -0300 @@ -33,7 +33,7 @@ protected void Application_Start() { ModelMetadataProviders.Current = - new DataAnnotationAndResolveByConventionModelMetadataProvider( + new DataAnnotationAndConventionModelMetadataProvider( new ResolverThroughResource<DataAnnotationResources>()); AreaRegistration.RegisterAllAreas();