ChannelDispatcher.ChannelInitializers 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得 IChannelInitializer 物件集合,在通道第一次建立時,您可以使用這些物件來檢查和加入通道狀態。
public:
property System::Collections::Generic::SynchronizedCollection<System::ServiceModel::Dispatcher::IChannelInitializer ^> ^ ChannelInitializers { System::Collections::Generic::SynchronizedCollection<System::ServiceModel::Dispatcher::IChannelInitializer ^> ^ get(); };
public System.Collections.Generic.SynchronizedCollection<System.ServiceModel.Dispatcher.IChannelInitializer> ChannelInitializers { get; }
member this.ChannelInitializers : System.Collections.Generic.SynchronizedCollection<System.ServiceModel.Dispatcher.IChannelInitializer>
Public ReadOnly Property ChannelInitializers As SynchronizedCollection(Of IChannelInitializer)
屬性值
SynchronizedCollection<T>,型別為 IChannelInitializer 物件。
範例
Uri baseAddress = new Uri("http://localhost:8001/Simple");
ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress);
serviceHost.AddServiceEndpoint(
typeof(ICalculator),
new WSHttpBinding(),
"CalculatorServiceObject");
serviceHost.Open();
ChannelDispatcher dispatcher = (ChannelDispatcher) serviceHost.ChannelDispatchers[0];
SynchronizedCollection<IChannelInitializer> col = dispatcher.ChannelInitializers;
Dim baseAddress As New Uri("http://localhost:8001/Simple")
Dim serviceHost As New ServiceHost(GetType(CalculatorService), baseAddress)
serviceHost.AddServiceEndpoint(GetType(ICalculator), New WSHttpBinding(), "CalculatorServiceObject")
serviceHost.Open()
Dim dispatcher As ChannelDispatcher = CType(serviceHost.ChannelDispatchers(0), ChannelDispatcher)
Dim col As SynchronizedCollection(Of IChannelInitializer) = dispatcher.ChannelInitializers
備註
使用這個屬性,即可將自訂通道初始設定式插入至初始設定集合 (Initialization Collection),以便在通道建立時檢查或修改通道狀態。 如果與發送器關聯的合約是雙工合約,這個屬性也可以用來對傳出通道執行相同的行為。