IInteractiveChannelInitializer 介面

定義

定義方法,這些方法可讓用戶端應用程式顯示使用者介面,以便在建立通道之前收集身分識別資訊。Defines the methods that enable a client application to display a user interface to collect identity information prior to creating the channel.

public interface class IInteractiveChannelInitializer
public interface IInteractiveChannelInitializer
type IInteractiveChannelInitializer = interface
Public Interface IInteractiveChannelInitializer
衍生

備註

實作 IInteractiveChannelInitializer 介面來讓用戶端應用程式顯示使用者介面,以供應用程式的使用者在開啟通道之前用來建立或選取認證。Implement the IInteractiveChannelInitializer interface to enable a client application to display a user interface that enables the user of the application to create or select the credentials prior to opening a channel.

為了實作 IInteractiveChannelInitializer,此時要在 IInteractiveChannelInitializer.BeginDisplayInitializationUI 中執行下列步驟:To implement IInteractiveChannelInitializer, perform the following steps in IInteractiveChannelInitializer.BeginDisplayInitializationUI:

  1. 提示使用者並取得適當的 System.Net.NetworkCredentialPrompt the user and obtain an appropriate System.Net.NetworkCredential.

  2. 將自訂通道參數物件加入至在 IChannel.GetProperty 物件上以 IClientChannel 的型別參數呼叫 System.ServiceModel.Channels.ChannelParameterCollection 方法所傳回的集合。Add a custom channel parameter object to the collection returned by the IChannel.GetProperty method on the IClientChannel object with a type parameter of System.ServiceModel.Channels.ChannelParameterCollection. 自訂的 System.ServiceModel.ClientCredentialsSecurityTokenManager 會使用這個通道參數物件來建立通道的安全性權杖。This channel parameter object is used by the custom System.ServiceModel.ClientCredentialsSecurityTokenManager to establish the security tokens for the channel.

  3. 傳回。Return.

為了插入 IInteractiveChannelInitializer,此時要:To insert IInteractiveChannelInitializer:

  1. 覆寫 IEndpointBehavior.ApplyClientBehavior 類別上的 System.ServiceModel.Description.ClientCredentials 方法。Override the IEndpointBehavior.ApplyClientBehavior method on the System.ServiceModel.Description.ClientCredentials class.

  2. 使用該方法來判定端點是否需要 IInteractiveChannelInitializer,如果需要,則將 IInteractiveChannelInitializer 加入至 ClientRuntime.InteractiveChannelInitializers 集合。In that method, determine whether the endpoint requires an IInteractiveChannelInitializer and if so, add the IInteractiveChannelInitializer to the ClientRuntime.InteractiveChannelInitializers collection.

應用程式開發人員可以透過兩種方式來使用插入的 IInteractiveChannelInitializerThere are two ways application developers can make use of an inserted IInteractiveChannelInitializer. 用戶端應用程式可以在 ClientBase<TChannel>.DisplayInitializationUI IClientChannel.DisplayInitializationUI 開啟通道 (明確 的) 方法之前,呼叫或 (或非同步版本) ,或直接呼叫第一項作業 (隱含 方法) 。The client application can call either ClientBase<TChannel>.DisplayInitializationUI or IClientChannel.DisplayInitializationUI (or an asynchronous version) prior to opening the channel (the explicit approach) or simply call the first operation (the implicit approach).

如果使用隱含方式,應用程式就必須在 ClientBase<TChannel>IClientChannel 擴充上呼叫第一項作業。If using the implicit approach, the application must call the first operation on an ClientBase<TChannel> or IClientChannel extension. 如果呼叫第一項作業以外的任何作業,就會擲回例外狀況。If it calls anything other than the first operation, an exception is thrown.

如果使用明確方式,應用程式必須依照順序執行下列步驟:If using the explicit approach, the application must perform the following steps in order:

  1. 呼叫 ClientBase<TChannel>.DisplayInitializationUIIClientChannel.DisplayInitializationUI (或非同步版本)。Call either ClientBase<TChannel>.DisplayInitializationUI or IClientChannel.DisplayInitializationUI (or an asynchronous version).

  2. 當初始設定式已回傳時,在 Open 物件或是 IClientChannel 屬性傳回的 IClientChannel 物件上呼叫 ClientBase<TChannel>.InnerChannel 方法。When the initializers have returned, call either the Open method on the IClientChannel object or on the IClientChannel object returned from the ClientBase<TChannel>.InnerChannel property.

  3. 呼叫作業。Call operations.

建議您採用明確方式來處理使用者介面的產品等級應用程式控制。It is recommended that production-quality applications control of the user-interface process by adopting the explicit approach.

使用隱含方式的應用程式會叫用使用者介面初始設定式,但若應用程式的使用者無法在繫結的傳送逾時期限之內回應,當使用者介面傳回時就會擲回例外狀況。Applications that use the implicit approach invoke the user-interface initializers, but if the user of the application fails to respond within the send timeout period of the binding, an exception is thrown when the user interface returns.

方法

BeginDisplayInitializationUI(IClientChannel, AsyncCallback, Object)

要開始使用使用者介面來取得認證資訊的非同步呼叫。An asynchronous call to begin using a user interface to obtain credential information.

EndDisplayInitializationUI(IAsyncResult)

BeginDisplayInitializationUI(IClientChannel, AsyncCallback, Object) 完成後呼叫。Called when the BeginDisplayInitializationUI(IClientChannel, AsyncCallback, Object) has finished.

適用於