ChannelDispatcher.ChannelInitializers 属性

定义

获取 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<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

注解

使用此属性可以将自定义通道初始值设定项插入到初始化集合中,以便在首次创建通道时检查和修改通道状态。 如果与调度程序相关联的协定是双工协定,这也很有用,可以在传出的通道上执行相同的行为。

适用于