Table of Contents

Class AssociatedMetadataProvider<TModelMetadata>

Namespace
System.Web.Http.Metadata.Providers
Assembly
System.Web.Http.dll

Provides an abstract class to implement a metadata provider.

public abstract class AssociatedMetadataProvider<TModelMetadata> : ModelMetadataProvider where TModelMetadata : ModelMetadata

Type Parameters

TModelMetadata

The type of the model metadata.

Inheritance
AssociatedMetadataProvider<TModelMetadata>
Derived
Inherited Members

Constructors

AssociatedMetadataProvider()

Initializes a new instance of the AssociatedMetadataProvider<TModelMetadata> class.

protected AssociatedMetadataProvider()

Methods

CreateMetadataFromPrototype(TModelMetadata, Func<object>)

When overridden in a derived class, creates the model metadata for the property using the specified prototype.

protected abstract TModelMetadata CreateMetadataFromPrototype(TModelMetadata prototype, Func<object> modelAccessor)

Parameters

prototype TModelMetadata

The prototype from which to create the model metadata.

modelAccessor Func<object>

The model accessor.

Returns

TModelMetadata

The model metadata for the property.

CreateMetadataPrototype(IEnumerable<Attribute>, Type, Type, string)

When overridden in a derived class, creates the model metadata for the property.

protected abstract TModelMetadata CreateMetadataPrototype(IEnumerable<Attribute> attributes, Type containerType, Type modelType, string propertyName)

Parameters

attributes IEnumerable<Attribute>

The set of attributes.

containerType Type

The type of the container.

modelType Type

The type of the model.

propertyName string

The name of the property.

Returns

TModelMetadata

The model metadata for the property.

GetMetadataForProperties(object, Type)

Retrieves a list of properties for the model.

public override sealed 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, string)

Retrieves the metadata for the specified property using the container type and property name.

public override sealed 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.

GetMetadataForType(Func<object>, Type)

Returns the metadata for the specified property using the type of the model.

public override sealed ModelMetadata GetMetadataForType(Func<object> modelAccessor, Type modelType)

Parameters

modelAccessor Func<object>

The model accessor.

modelType Type

The type of the container.

Returns

ModelMetadata

The metadata for the specified property.