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. 它也可讓您透過任何執行介面的服務來新增自訂驗證 IServiceProviderIt 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>)

使用服務提供者將 ValidationContext 初始化;呼叫 GetService(Type) 時,此服務提供者會依型別傳回服務執行個體。Initializes the ValidationContext using a service provider that can return service instances by type when GetService(Type) is called.

MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

適用於