ValidationContext Конструкторы

Определение

Инициализирует новый экземпляр класса ValidationContext.

Перегрузки

Имя Описание
ValidationContext(Object)

Инициализирует новый экземпляр класса с помощью указанного ValidationContext экземпляра объекта.

ValidationContext(Object, IDictionary<Object,Object>)

Инициализирует новый экземпляр ValidationContext класса, используя указанный объект и необязательный контейнер свойств.

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

Инициализирует новый экземпляр ValidationContext класса с помощью поставщика услуг и словаря потребителей служб.

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

Создает объект ValidationContext для данного экземпляра объекта с displayNameнеобязательным и необязательным serviceProviderконтейнером itemsсвойств.

ValidationContext(Object)

Исходный код:
ValidationContext.cs
Исходный код:
ValidationContext.cs
Исходный код:
ValidationContext.cs
Исходный код:
ValidationContext.cs
Исходный код:
ValidationContext.cs

Инициализирует новый экземпляр класса с помощью указанного ValidationContext экземпляра объекта.

public:
 ValidationContext(System::Object ^ instance);
public ValidationContext(object instance);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Constructing a ValidationContext without a display name is not trim-safe because it uses reflection to discover the type of the instance being validated in order to resolve the DisplayNameAttribute when a display name is not provided.")]
public ValidationContext(object instance);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")]
public ValidationContext(object instance);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of instance cannot be statically discovered and the Type's properties can be trimmed.")]
public ValidationContext(object instance);
new System.ComponentModel.DataAnnotations.ValidationContext : obj -> System.ComponentModel.DataAnnotations.ValidationContext
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Constructing a ValidationContext without a display name is not trim-safe because it uses reflection to discover the type of the instance being validated in order to resolve the DisplayNameAttribute when a display name is not provided.")>]
new System.ComponentModel.DataAnnotations.ValidationContext : obj -> System.ComponentModel.DataAnnotations.ValidationContext
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")>]
new System.ComponentModel.DataAnnotations.ValidationContext : obj -> System.ComponentModel.DataAnnotations.ValidationContext
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of instance cannot be statically discovered and the Type's properties can be trimmed.")>]
new System.ComponentModel.DataAnnotations.ValidationContext : obj -> System.ComponentModel.DataAnnotations.ValidationContext
Public Sub New (instance As Object)

Параметры

instance
Object

Экземпляр объекта для проверки. Его нельзя null.

Атрибуты

Исключения

instance равно null.

Применяется к

ValidationContext(Object, IDictionary<Object,Object>)

Исходный код:
ValidationContext.cs
Исходный код:
ValidationContext.cs
Исходный код:
ValidationContext.cs
Исходный код:
ValidationContext.cs
Исходный код:
ValidationContext.cs

Инициализирует новый экземпляр ValidationContext класса, используя указанный объект и необязательный контейнер свойств.

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);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Constructing a ValidationContext without a display name is not trim-safe because it uses reflection to discover the type of the instance being validated in order to resolve the DisplayNameAttribute when a display name is not provided.")]
public ValidationContext(object instance, System.Collections.Generic.IDictionary<object,object?>? items);
public ValidationContext(object instance, System.Collections.Generic.IDictionary<object,object?>? items);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")]
public ValidationContext(object instance, System.Collections.Generic.IDictionary<object,object?>? items);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of instance cannot be statically discovered and the Type's properties can be trimmed.")]
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
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Constructing a ValidationContext without a display name is not trim-safe because it uses reflection to discover the type of the instance being validated in order to resolve the DisplayNameAttribute when a display name is not provided.")>]
new System.ComponentModel.DataAnnotations.ValidationContext : obj * System.Collections.Generic.IDictionary<obj, obj> -> System.ComponentModel.DataAnnotations.ValidationContext
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")>]
new System.ComponentModel.DataAnnotations.ValidationContext : obj * System.Collections.Generic.IDictionary<obj, obj> -> System.ComponentModel.DataAnnotations.ValidationContext
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of instance cannot be statically discovered and the Type's properties can be trimmed.")>]
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

Экземпляр объекта для проверки. Его нельзя null.

items
IDictionary<Object,Object>

Необязательный набор пар "ключ-значение", чтобы сделать доступными для потребителей.

Атрибуты

Исключения

instance равно null.

Комментарии

Если items есть null, создается пустой словарь. Если items значение не равно null, набор пар "ключ-значение" копируется в новый словарь, предотвращая изменение исходного словаря потребителями.

Применяется к

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

Исходный код:
ValidationContext.cs
Исходный код:
ValidationContext.cs
Исходный код:
ValidationContext.cs
Исходный код:
ValidationContext.cs
Исходный код:
ValidationContext.cs

Инициализирует новый экземпляр ValidationContext класса с помощью поставщика услуг и словаря потребителей служб.

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);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Constructing a ValidationContext without a display name is not trim-safe because it uses reflection to discover the type of the instance being validated in order to resolve the DisplayNameAttribute when a display name is not provided.")]
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);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")]
public ValidationContext(object instance, IServiceProvider? serviceProvider, System.Collections.Generic.IDictionary<object,object?>? items);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of instance cannot be statically discovered and the Type's properties can be trimmed.")]
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
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Constructing a ValidationContext without a display name is not trim-safe because it uses reflection to discover the type of the instance being validated in order to resolve the DisplayNameAttribute when a display name is not provided.")>]
new System.ComponentModel.DataAnnotations.ValidationContext : obj * IServiceProvider * System.Collections.Generic.IDictionary<obj, obj> -> System.ComponentModel.DataAnnotations.ValidationContext
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")>]
new System.ComponentModel.DataAnnotations.ValidationContext : obj * IServiceProvider * System.Collections.Generic.IDictionary<obj, obj> -> System.ComponentModel.DataAnnotations.ValidationContext
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of instance cannot be statically discovered and the Type's properties can be trimmed.")>]
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

Объект для проверки. Этот параметр является обязательным.

serviceProvider
IServiceProvider

Объект, реализующий IServiceProvider интерфейс. Это необязательный параметр.

items
IDictionary<Object,Object>

Словарь пар "ключ-значение", чтобы сделать доступными для потребителей служб. Это необязательный параметр.

Атрибуты

Исключения

instance равно null.

Комментарии

Параметр serviceProvider представляет службу, которую можно использовать методом GetService для выполнения пользовательской проверки.

items Если параметр имеет значениеnull, создается пустой словарь. Если параметр не nullявляется, набор пар "ключ-значение" копируется в новый словарь, который запрещает потребителям служб изменять исходный словарь.

Применяется к

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

Исходный код:
ValidationContext.cs
Исходный код:
ValidationContext.cs

Создает объект ValidationContext для данного экземпляра объекта с displayNameнеобязательным и необязательным serviceProviderконтейнером itemsсвойств.

public:
 ValidationContext(System::Object ^ instance, System::String ^ displayName, IServiceProvider ^ serviceProvider, System::Collections::Generic::IDictionary<System::Object ^, System::Object ^> ^ items);
public ValidationContext(object instance, string displayName, IServiceProvider? serviceProvider, System.Collections.Generic.IDictionary<object,object?>? items);
new System.ComponentModel.DataAnnotations.ValidationContext : obj * string * IServiceProvider * System.Collections.Generic.IDictionary<obj, obj> -> System.ComponentModel.DataAnnotations.ValidationContext
Public Sub New (instance As Object, displayName As String, serviceProvider As IServiceProvider, items As IDictionary(Of Object, Object))

Параметры

instance
Object

Проверяемый экземпляр объекта. Его нельзя null.

displayName
String

Отображаемое имя, связанное с экземпляром объекта.

serviceProvider
IServiceProvider

Необязательно IServiceProvider использовать при GetService(Type) вызове.

Если это так null, GetService(Type) всегда возвращается null.

items
IDictionary<Object,Object>

Необязательный набор пар "ключ-значение", чтобы сделать доступными для потребителей через Items.

Если nullбудет создан пустой словарь. Если нет null, набор пар "ключ-значение" будет скопирован в новый словарь, предотвращая изменение исходного словаря потребителями.

Исключения

Когда instance есть null

Комментарии

Этот конструктор является обрезным, так как он не использует отражение для разрешения типа instance параметра DisplayName.

Применяется к