ValidationContext 建構函式

定義

初始化 ValidationContext 類別的新執行個體。

多載

ValidationContext(Object)

使用指定的物件執行個體,初始化 ValidationContext 類別的新執行個體。

ValidationContext(Object, IDictionary<Object,Object>)

使用指定的物件和選擇性屬性包,初始化 ValidationContext 類別的新執行個體。

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

使用服務提供者和服務取用者的字典,初始化 ValidationContext 類別的新執行個體。

ValidationContext(Object)

來源:
ValidationContext.cs
來源:
ValidationContext.cs
來源:
ValidationContext.cs

使用指定的物件執行個體,初始化 ValidationContext 類別的新執行個體。

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

要驗證的物件執行個體。 不可為 null

例外狀況

instancenull

適用於

ValidationContext(Object, IDictionary<Object,Object>)

來源:
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);
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

要驗證的物件執行個體。 不可為 null

items
IDictionary<Object,Object>

要提供給消費者的選擇性索引鍵/值組集合。

例外狀況

instancenull

備註

如果 itemsnull,則會建立空的字典。 如果 items 不是 Null,則會將索引鍵/值組集合複製到新的字典,以防止取用者修改原始字典。

適用於

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

來源:
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);
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

要驗證的物件。 這是必要參數。

serviceProvider
IServiceProvider

實作 IServiceProvider 介面的物件。 這是選擇性參數。

items
IDictionary<Object,Object>

要提供給服務消費者之索引鍵/值組的字典。 這是選擇性參數。

例外狀況

instancenull

備註

參數 serviceProvider 代表方法可用來 GetService 執行自定義驗證的服務。

items如果 參數為 null,則會建立空的字典。 如果 參數不是 null,則會將索引鍵/值組集合複製到新的字典中,以防止服務取用者修改原始字典。

適用於