Freigeben über


AssociatedMetadataProvider Class

Provides an abstract class to implement a metadata provider.

Inheritance Hierarchy

System.Object
  System.Web.Mvc.ModelMetadataProvider
    System.Web.Mvc.AssociatedMetadataProvider
      System.Web.Mvc.DataAnnotationsModelMetadataProvider
      System.Web.Mvc.EmptyModelMetadataProvider

Namespace:  System.Web.Mvc
Assembly:  System.Web.Mvc (in System.Web.Mvc.dll)

Syntax

'Declaration
Public MustInherit Class AssociatedMetadataProvider _
    Inherits ModelMetadataProvider
public abstract class AssociatedMetadataProvider : ModelMetadataProvider
public ref class AssociatedMetadataProvider abstract : public ModelMetadataProvider

The AssociatedMetadataProvider type exposes the following members.

Constructors

  Name Description
Protected method AssociatedMetadataProvider Called from constructors in a derived class to initialize the AssociatedMetadataProvider class.

Top

Methods

  Name Description
Protected method CreateMetadata When overridden in a derived class, creates the model metadata for the property.
Public method Equals Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method FilterAttributes Gets a list of attributes.
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetMetadataForProperties Returns a list of properties for the model. (Overrides ModelMetadataProvider.GetMetadataForProperties(Object, Type).)
Protected method GetMetadataForProperty(Func<Object>, Type, PropertyDescriptor) Returns the metadata for the specified property using the container type and property descriptor.
Public method GetMetadataForProperty(Func<Object>, Type, String) Returns the metadata for the specified property using the container type and property name. (Overrides ModelMetadataProvider.GetMetadataForProperty(Func<Object>, Type, String).)
Public method GetMetadataForType Returns the metadata for the specified property using the type of the model. (Overrides ModelMetadataProvider.GetMetadataForType(Func<Object>, Type).)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method GetTypeDescriptor Returns the type descriptor from the specified type.
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Remarks

A metadata provider provides metadata for the model within a view. Metadata providers must derive from ModelMetadataProvider. You can inherit from this class if you want to use a custom validator or a third-party validator that uses attribute-based metadata.

This class implements the abstract methods of ModelMetadataProvider and contains only one additional abstract method. When you implement this class, use the AssociatedValidatorProvider class to implement the validator.

Model provider classes and validator provider classes are loosely coupled. Therefore, they work independently, and have no dependencies on each other.

However, the metadata provider exposes metadata that can be accessed and used by validation providers. For example, the MVC default metadata provider (the DataAnnotationsModelMetadataProvider class) reads the display name of an object, and the display name is used by the DataAnnotationsModelValidatorProvider validation provider when it creates a validation error message.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

System.Web.Mvc Namespace