I'm building a custom MetadataProvider and I'd like to access the actuall model value in the CreateMetadata
method.
public class IcpMetadataProvider : AssociatedMetadataProvider
{
protected override ModelMetadata CreateMetadata(IEnumerable<Attribute> attributes, Type containerType, Func<object> modelAccessor, Type modelType, string propertyName)
{
var metadata = new ModelMetadata(this, containerType, modelAccessor, modelType, propertyName);
//Is null when the model is of reference type
var model = metadata.Model;
return metadata;
}
}
When the current model value is of type string, the model value can be found in metadata.Model
. But when the model is of reference type the value is null.
Or maybe is there any way to pass custom data to this method ?