Class AssociatedMetadataProvider
Provides an abstract class to implement a metadata provider.
public abstract class AssociatedMetadataProvider : ModelMetadataProvider
- Inheritance
-
AssociatedMetadataProvider
- Derived
- Inherited Members
Constructors
AssociatedMetadataProvider()
Called from constructors in a derived class to initialize the AssociatedMetadataProvider class.
protected AssociatedMetadataProvider()
Methods
CreateMetadata(IEnumerable<Attribute>, Type, Func<object>, Type, string)
When overridden in a derived class, creates the model metadata for the property.
protected abstract ModelMetadata CreateMetadata(IEnumerable<Attribute> attributes, Type containerType, Func<object> modelAccessor, Type modelType, string propertyName)
Parameters
attributes
IEnumerable<Attribute>The set of attributes.
containerType
TypeThe type of the container.
modelAccessor
Func<object>The model accessor.
modelType
TypeThe type of the model.
propertyName
stringThe name of the property.
Returns
- ModelMetadata
The model metadata for the property.
FilterAttributes(Type, PropertyDescriptor, IEnumerable<Attribute>)
Gets a list of attributes.
protected virtual IEnumerable<Attribute> FilterAttributes(Type containerType, PropertyDescriptor propertyDescriptor, IEnumerable<Attribute> attributes)
Parameters
containerType
TypeThe type of the container.
propertyDescriptor
PropertyDescriptorThe property descriptor.
attributes
IEnumerable<Attribute>The attribute container.
Returns
- IEnumerable<Attribute>
A list of attributes.
GetMetadataForProperties(object, Type)
Returns a list of properties for the model.
public override IEnumerable<ModelMetadata> GetMetadataForProperties(object container, Type containerType)
Parameters
Returns
- IEnumerable<ModelMetadata>
A list of properties for the model.
GetMetadataForProperty(Func<object>, Type, PropertyDescriptor)
Returns the metadata for the specified property using the container type and property descriptor.
protected virtual ModelMetadata GetMetadataForProperty(Func<object> modelAccessor, Type containerType, PropertyDescriptor propertyDescriptor)
Parameters
modelAccessor
Func<object>The model accessor.
containerType
TypeThe type of the container.
propertyDescriptor
PropertyDescriptorThe property descriptor
Returns
- ModelMetadata
The metadata for the specified property using the container type and property descriptor.
GetMetadataForProperty(Func<object>, Type, string)
Returns the metadata for the specified property using the container type and property name.
public override ModelMetadata GetMetadataForProperty(Func<object> modelAccessor, Type containerType, string propertyName)
Parameters
modelAccessor
Func<object>The model accessor.
containerType
TypeThe type of the container.
propertyName
stringThe name of the property.
Returns
- ModelMetadata
The metadata for the specified property using the container type and property name.
GetMetadataForType(Func<object>, Type)
Returns the metadata for the specified property using the type of the model.
public override ModelMetadata GetMetadataForType(Func<object> modelAccessor, Type modelType)
Parameters
Returns
- ModelMetadata
The metadata for the specified property using the type of the model.
GetTypeDescriptor(Type)
Returns the type descriptor from the specified type.
protected virtual ICustomTypeDescriptor GetTypeDescriptor(Type type)
Parameters
type
TypeThe type.
Returns
- ICustomTypeDescriptor
The type descriptor.