Table of Contents

Class CachedAssociatedMetadataProvider<TModelMetadata>

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

Provides an abstract class to implement a cached metadata provider.

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

Type Parameters

TModelMetadata
Inheritance
CachedAssociatedMetadataProvider<TModelMetadata>
Derived
Inherited Members

Constructors

CachedAssociatedMetadataProvider()

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

protected CachedAssociatedMetadataProvider()

Properties

CacheItemPolicy

Gets the cache item policy.

protected CacheItemPolicy CacheItemPolicy { get; set; }

Property Value

CacheItemPolicy

The cache item policy.

CacheKeyPrefix

Gets the cache key prefix.

protected string CacheKeyPrefix { get; }

Property Value

string

The cache key prefix.

PrototypeCache

Gets the prototype cache.

protected ObjectCache PrototypeCache { get; set; }

Property Value

ObjectCache

The prototype cache.

Methods

CreateMetadata(IEnumerable<Attribute>, Type, Func<object>, Type, string)

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

protected override sealed ModelMetadata CreateMetadata(IEnumerable<Attribute> attributes, Type containerType, Func<object> modelAccessor, Type modelType, string propertyName)

Parameters

attributes IEnumerable<Attribute>

The attributes.

containerType Type

The container type.

modelAccessor Func<object>

The model accessor.

modelType Type

The model type.

propertyName string

The property name.

Returns

ModelMetadata

The cached model metadata for the property.

CreateMetadataFromPrototype(TModelMetadata, Func<object>)

Creates prototype metadata by applying the prototype and model access to yield the final metadata.

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

Parameters

prototype TModelMetadata

The prototype.

modelAccessor Func<object>

The model accessor.

Returns

TModelMetadata

The prototype metadata.

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

Creates a metadata prototype.

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

Parameters

attributes IEnumerable<Attribute>

The attributes.

containerType Type

The container type.

modelType Type

The model type.

propertyName string

The property name.

Returns

TModelMetadata

A metadata prototype.

GetMetadataForProperties(object, Type)

Gets the metadata for the properties.

public override sealed IEnumerable<ModelMetadata> GetMetadataForProperties(object container, Type containerType)

Parameters

container object

The container.

containerType Type

The container type.

Returns

IEnumerable<ModelMetadata>

The metadata for the properties.

GetMetadataForProperty(Func<object>, Type, PropertyDescriptor)

Returns the metadata for the specified property.

protected override sealed ModelMetadata GetMetadataForProperty(Func<object> modelAccessor, Type containerType, PropertyDescriptor propertyDescriptor)

Parameters

modelAccessor Func<object>

The model accessor.

containerType Type

The container type.

propertyDescriptor PropertyDescriptor

The property descriptor.

Returns

ModelMetadata

The metadata for the specified property.

GetMetadataForProperty(Func<object>, Type, string)

Returns the metadata for the specified property.

public override sealed ModelMetadata GetMetadataForProperty(Func<object> modelAccessor, Type containerType, string propertyName)

Parameters

modelAccessor Func<object>

The model accessor.

containerType Type

The container type.

propertyName string

The property name.

Returns

ModelMetadata

The metadata for the specified property.

GetMetadataForType(Func<object>, Type)

Returns the cached 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 cached metadata for the specified property using the type of the model.