ValidationContext 构造函数
定义
初始化 ValidationContext 类的新实例。Initializes a new instance of the ValidationContext class.
重载
| 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. |
ValidationContext(Object)
使用指定的对象实例初始化 ValidationContext 类的新实例。Initializes a new instance of the ValidationContext class using the specified object instance.
public:
ValidationContext(System::Object ^ instance);
public ValidationContext (object instance);
new System.ComponentModel.DataAnnotations.ValidationContext : obj -> System.ComponentModel.DataAnnotations.ValidationContext
Public Sub New (instance As Object)
参数
- instance
- Object
要验证的对象实例。The object instance to validate. 它不能为 null。It cannot be null.
例外
instance 为 null。instance is null.
适用于
ValidationContext(Object, IDictionary<Object,Object>)
使用指定的目标对象和一个可选择的属性包初始化 ValidationContext 类的新实例。Initializes a new instance of the ValidationContext class using the specified object and an optional property bag.
public:
ValidationContext(System::Object ^ instance, System::Collections::Generic::IDictionary<System::Object ^, System::Object ^> ^ items);
public ValidationContext (object instance, System.Collections.Generic.IDictionary<object,object> items);
public ValidationContext (object instance, System.Collections.Generic.IDictionary<object,object?>? items);
new System.ComponentModel.DataAnnotations.ValidationContext : obj * System.Collections.Generic.IDictionary<obj, obj> -> System.ComponentModel.DataAnnotations.ValidationContext
Public Sub New (instance As Object, items As IDictionary(Of Object, Object))
参数
- instance
- Object
要验证的对象实例。The object instance to validate. 它不能为 nullIt cannot be null
- items
- IDictionary<Object,Object>
使用者可访问的、可选的键/值对集合。An optional set of key/value pairs to make available to consumers.
例外
instance 为 null。instance is null.
注解
如果 items 是 null,则创建一个空字典。If items is null, an empty dictionary is created. 如果 items 不为 null,则该组键/值对将复制到新字典中,并阻止使用者修改原始字典。If items is not null, the set of key/value pairs is copied into a new dictionary, preventing consumers from modifying the original dictionary.
适用于
ValidationContext(Object, IServiceProvider, IDictionary<Object,Object>)
使用服务提供程序和客户服务字典初始化 ValidationContext 类的新实例。Initializes a new instance of the ValidationContext class using the service provider and dictionary of service consumers.
public:
ValidationContext(System::Object ^ instance, IServiceProvider ^ serviceProvider, System::Collections::Generic::IDictionary<System::Object ^, System::Object ^> ^ items);
public ValidationContext (object instance, IServiceProvider serviceProvider, System.Collections.Generic.IDictionary<object,object> items);
public ValidationContext (object instance, IServiceProvider? serviceProvider, System.Collections.Generic.IDictionary<object,object?>? items);
new System.ComponentModel.DataAnnotations.ValidationContext : obj * IServiceProvider * System.Collections.Generic.IDictionary<obj, obj> -> System.ComponentModel.DataAnnotations.ValidationContext
Public Sub New (instance As Object, serviceProvider As IServiceProvider, items As IDictionary(Of Object, Object))
参数
- instance
- Object
要验证的对象。The object to validate. 此参数是必需的。This parameter is required.
- serviceProvider
- IServiceProvider
实现 IServiceProvider 接口的对象。The object that implements the IServiceProvider interface. 此参数可选。This parameter is optional.
- items
- IDictionary<Object,Object>
要提供给服务使用方的键/值对的字典。A dictionary of key/value pairs to make available to the service consumers. 此参数可选。This parameter is optional.
例外
instance 为 null。instance is null.
注解
serviceProvider参数表示可由 GetService 方法用来执行自定义验证的服务。The serviceProvider parameter represents a service that can be used by the GetService method in order to perform custom validation.
如果 items 参数为 null ,则创建一个空字典。If the items parameter is null, an empty dictionary is created. 如果参数不为,则将 null 键/值对集合复制到新字典中,这会阻止服务使用者修改原始字典。If the parameter is not null, the set of key/value pairs is copied into a new dictionary, which prevents the service consumers from modifying the original dictionary.