protected override void InitializeRuntime() { MessageFilter contractFilter = this.listenerFilter; int filterPriority = 10; Type[] endpointChannelTypes = new Type[] { typeof(IReplyChannel), typeof(IDuplexChannel), typeof(IReplySessionChannel), typeof(IDuplexSessionChannel) }; IChannelListener listener = null; BindingParameterCollection parameters = new BindingParameterCollection(this.channelBuilder.BindingParameters); Binding binding = this.channelBuilder.Binding; binding.ReceiveTimeout = this.authenticator.NegotiationTimeout; parameters.Add(new ChannelDemuxerFilter(contractFilter, filterPriority)); DispatcherBuilder.MaybeCreateListener(true, endpointChannelTypes, binding, parameters, this.listenUri, "", ListenUriMode.Explicit, this.ServiceThrottle, out listener); if (listener == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.CannotCreateTwoWayListenerForNegotiation))); } ChannelDispatcher channelDispatcher = new ChannelDispatcher(listener, null, binding); channelDispatcher.MessageVersion = binding.MessageVersion; channelDispatcher.ManualAddressing = true; channelDispatcher.ServiceThrottle = new ServiceThrottle(this); channelDispatcher.ServiceThrottle.MaxConcurrentCalls = this.authenticator.MaximumConcurrentNegotiations; channelDispatcher.ServiceThrottle.MaxConcurrentSessions = this.authenticator.MaximumConcurrentNegotiations; EndpointDispatcher endpointDispatcher = new EndpointDispatcher(new EndpointAddress(this.listenUri), "SecurityNegotiationContract", NamingHelper.DefaultNamespace, true); endpointDispatcher.DispatchRuntime.SingletonInstanceContext = new InstanceContext(null, this.authenticator, false); endpointDispatcher.DispatchRuntime.ConcurrencyMode = ConcurrencyMode.Multiple; endpointDispatcher.AddressFilter = new MatchAllMessageFilter(); endpointDispatcher.ContractFilter = contractFilter; endpointDispatcher.FilterPriority = filterPriority; endpointDispatcher.DispatchRuntime.PrincipalPermissionMode = PrincipalPermissionMode.None; endpointDispatcher.DispatchRuntime.InstanceContextProvider = new SingletonInstanceContextProvider(endpointDispatcher.DispatchRuntime); endpointDispatcher.DispatchRuntime.SynchronizationContext = null; DispatchOperation operation = new DispatchOperation(endpointDispatcher.DispatchRuntime, "*", MessageHeaders.WildcardAction, MessageHeaders.WildcardAction); operation.Formatter = new MessageOperationFormatter(); operation.Invoker = new NegotiationSyncInvoker(this.authenticator); endpointDispatcher.DispatchRuntime.UnhandledDispatchOperation = operation; channelDispatcher.Endpoints.Add(endpointDispatcher); this.ChannelDispatchers.Add(channelDispatcher); }
protected override void InitializeRuntime() { MessageFilter listenerFilter = this.listenerFilter; int priority = 10; System.Type[] supportedChannels = new System.Type[] { typeof(IReplyChannel), typeof(IDuplexChannel), typeof(IReplySessionChannel), typeof(IDuplexSessionChannel) }; IChannelListener result = null; BindingParameterCollection parameters = new BindingParameterCollection(this.channelBuilder.BindingParameters); Binding binding = this.channelBuilder.Binding; binding.ReceiveTimeout = this.authenticator.NegotiationTimeout; parameters.Add(new ChannelDemuxerFilter(listenerFilter, priority)); DispatcherBuilder.MaybeCreateListener(true, supportedChannels, binding, parameters, this.listenUri, "", ListenUriMode.Explicit, base.ServiceThrottle, out result); if (result == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("CannotCreateTwoWayListenerForNegotiation"))); } ChannelDispatcher item = new ChannelDispatcher(result, null, binding) { MessageVersion = binding.MessageVersion, ManualAddressing = true, ServiceThrottle = new ServiceThrottle(this) }; item.ServiceThrottle.MaxConcurrentCalls = this.authenticator.MaximumConcurrentNegotiations; item.ServiceThrottle.MaxConcurrentSessions = this.authenticator.MaximumConcurrentNegotiations; EndpointDispatcher dispatcher2 = new EndpointDispatcher(new EndpointAddress(this.listenUri, new AddressHeader[0]), "SecurityNegotiationContract", "http://tempuri.org/", true) { DispatchRuntime = { SingletonInstanceContext = new InstanceContext(null, this.authenticator, false), ConcurrencyMode = ConcurrencyMode.Multiple }, AddressFilter = new MatchAllMessageFilter(), ContractFilter = listenerFilter, FilterPriority = priority }; dispatcher2.DispatchRuntime.PrincipalPermissionMode = PrincipalPermissionMode.None; dispatcher2.DispatchRuntime.InstanceContextProvider = new SingletonInstanceContextProvider(dispatcher2.DispatchRuntime); dispatcher2.DispatchRuntime.SynchronizationContext = null; DispatchOperation operation = new DispatchOperation(dispatcher2.DispatchRuntime, "*", "*", "*") { Formatter = new MessageOperationFormatter(), Invoker = new NegotiationSyncInvoker <T>(this.authenticator) }; dispatcher2.DispatchRuntime.UnhandledDispatchOperation = operation; item.Endpoints.Add(dispatcher2); base.ChannelDispatchers.Add(item); }