Пример #1
0
        internal ChannelDispatcher BuildChannelDispatcher(Type serviceType, ServiceEndpoint se, BindingParameterCollection commonParams)
        {
            //Let all behaviors add their binding parameters
            AddBindingParameters(commonParams, se);
            //User the binding parameters to build the channel listener and Dispatcher
            IChannelListener  lf = BuildListener(se, commonParams);
            ChannelDispatcher cd = new ChannelDispatcher(
                lf, se.Binding.Name);

            cd.InitializeServiceEndpoint(serviceType, se);
            return(cd);
        }
Пример #2
0
        internal ChannelDispatcher BuildChannelDispatcher(Type serviceType, ServiceEndpoint se, BindingParameterCollection commonParams)
        {
            //Let all behaviors add their binding parameters
            AddBindingParameters(commonParams, se);

            // See if there's an existing channel that matches this endpoint
            var version = se.Binding.GetProperty <MessageVersion> (commonParams);

            if (version == null)
            {
                throw new InvalidOperationException("At least one BindingElement in the Binding must override GetProperty method to return a MessageVersion and no prior binding element should return null instead of calling GetInnerProperty method on BindingContext.");
            }

            ChannelDispatcher  cd = FindExistingDispatcher(se);
            EndpointDispatcher ep;

            if (cd != null)
            {
                ep = cd.InitializeServiceEndpoint(serviceType, se);
            }
            else
            {
                // Use the binding parameters to build the channel listener and Dispatcher.
                lock (HttpTransportBindingElement.ListenerBuildLock)
                {
                    ServiceHostBase.CurrentServiceHostHack = host;
                    IChannelListener lf = BuildListener(se, commonParams);
                    cd = new ChannelDispatcher(lf, se.Binding.Name);
                    cd.MessageVersion = version;
                    if (ChannelDispatcherSetter != null)
                    {
                        ChannelDispatcherSetter(cd);
                        ChannelDispatcherSetter = null;
                    }
                    ServiceHostBase.CurrentServiceHostHack = null;
                }
                ep = cd.InitializeServiceEndpoint(serviceType, se);
                built_dispatchers.Add(se.Binding, cd);
            }
            ep_to_dispatcher_ep[se] = ep;
            return(cd);
        }