Created
November 22, 2011 02:46
-
-
Save CraigCav/1384744 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomModelMetadataProvider : DataAnnotationsModelMetadataProvider | |
{ | |
protected override ModelMetadata CreateMetadata(IEnumerable<Attribute> attributes, Type containerType, Func<object> modelAccessor, Type modelType, string propertyName) | |
{ | |
var attributeList = attributes.ToList(); | |
var modelMetadata = base.CreateMetadata(attributeList, containerType, modelAccessor, modelType, propertyName); | |
ProvideTextAreaForBigText(modelMetadata, propertyName); | |
return modelMetadata; | |
} | |
private void ProvideTextAreaForBigText(ModelMetadata modelMetadata, string propertyName) | |
{ | |
if (propertyName != null && propertyName.EndsWith("_BigText") && string.IsNullOrEmpty(modelMetadata.TemplateHint)) | |
modelMetadata.TemplateHint = "BigText"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment