Table of Contents

Class AssociatedMetadataProvider

Namespace
System.Web.Mvc
Assembly
System.Web.Mvc.dll

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 Type

The type of the container.

modelAccessor Func<object>

The model accessor.

modelType Type

The type of the model.

propertyName string

The 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 Type

The type of the container.

propertyDescriptor PropertyDescriptor

The 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

container object

The model container.

containerType Type

The type of the container.

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 Type

The type of the container.

propertyDescriptor PropertyDescriptor

The 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 Type

The type of the container.

propertyName string

The 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

modelAccessor Func<object>

The model accessor.

modelType Type

The type of the model.

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 Type

The type.

Returns

ICustomTypeDescriptor

The type descriptor.