Modifica

Condividi tramite


ChannelDispatcher.ChannelInitializers Property

Definition

Gets a set of IChannelInitializer objects that you can use to inspect and add state to channels when they are first created.

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)

Property Value

A SynchronizedCollection<T> of type IChannelInitializer objects.

Examples

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

Remarks

Use this property to insert a custom channel initializer into the initialization collection to inspect or modify channel state when they are created. This is also useful to perform the same behavior on outgoing channels if the contract associated with a dispatcher is a duplex contract.

Applies to