ValidationContext.GetService(Type) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
回傳提供自訂驗證的服務。
public:
virtual System::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 該方法以取得服務的物件。