ValidationContext.GetService(Type) 方法

定義

傳回提供自訂驗證的服務。

public:
 virtual System::Object ^ GetService(Type ^ serviceType);
public object GetService (Type serviceType);
public object? GetService (Type serviceType);
abstract member GetService : Type -> obj
override this.GetService : Type -> obj
Public Function GetService (serviceType As Type) As Object

參數

serviceType
Type

要用於驗證的服務類型。

傳回

服務的執行個體;如果無法使用服務,則為 null

實作

備註

ServiceContainer如果物件是在應用層級定義,方法會GetService存取它以擷取所要求的服務。

ServiceContainer如果未定義物件或未傳回服務,GetService方法會查詢IServiceProvider傳遞至 ValidationContext 方法的物件,以取得服務。

適用於

另請參閱