ValidationContext 类

定义

描述执行验证检查的上下文。Describes the context in which a validation check is performed.

public ref class ValidationContext sealed : IServiceProvider
public sealed class ValidationContext : IServiceProvider
type ValidationContext = class
    interface IServiceProvider
Public NotInheritable Class ValidationContext
Implements IServiceProvider
继承
ValidationContext
实现

注解

此类描述要对其执行验证的类型或成员。This class describes the type or member on which validation is performed. 它还允许通过实现 IServiceProvider 接口的任何服务添加自定义验证。It also enables custom validation to be added through any service that implements the IServiceProvider interface.

构造函数

ValidationContext(Object)

使用指定的对象实例初始化 ValidationContext 类的新实例。Initializes a new instance of the ValidationContext class using the specified object instance.

ValidationContext(Object, IDictionary<Object,Object>)

使用指定的目标对象和一个可选择的属性包初始化 ValidationContext 类的新实例。Initializes a new instance of the ValidationContext class using the specified object and an optional property bag.

ValidationContext(Object, IServiceProvider, IDictionary<Object,Object>)

使用服务提供程序和客户服务字典初始化 ValidationContext 类的新实例。Initializes a new instance of the ValidationContext class using the service provider and dictionary of service consumers.

属性

DisplayName

获取或设置要验证的成员的名称。Gets or sets the name of the member to validate.

Items

获取与此上下文关联的键/值对的字典。Gets the dictionary of key/value pairs that is associated with this context.

MemberName

获取或设置要验证的成员的名称。Gets or sets the name of the member to validate.

ObjectInstance

获取要验证的对象。Gets the object to validate.

ObjectType

获取要验证的对象的类型。Gets the type of the object to validate.

ServiceContainer

获取验证服务容器。Gets the validation services container.

方法

Equals(Object)

确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetService(Type)

返回提供自定义验证的服务。Returns the service that provides custom validation.

GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
InitializeServiceProvider(Func<Type,Object>)

在调用 ValidationContextGetService 时,使用可以按类型返回服务实例的服务提供程序初始化 Initializes the ValidationContext using a service provider that can return service instances by type when GetService is called.

MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)

适用于