예제 #1
0
        internal TypedChannelDemuxer GetTypedServiceDispatcher(Type channelType, BindingParameterCollection bindingParameters)
        {
            TypedChannelDemuxer typeDemuxer = null;

            //if (typeof(TChannel) == typeof(IInputChannel))
            //{
            //    if (this.inputDemuxer == null)
            //    {
            //        if (context.CanBuildInnerChannelListener<IReplyChannel>())
            //            this.inputDemuxer = this.replyDemuxer = new ReplyChannelDemuxer(context);
            //        else
            //            this.inputDemuxer = new InputChannelDemuxer(context);
            //        createdDemuxer = true;
            //    }
            //    typeDemuxer = this.inputDemuxer;
            //}
            //else
            Type parentType = GetParentType(channelType);

            if (parentType == typeof(IReplyChannel))
            {
                if (_replyDemuxer == null)
                {
                    lock (_thisLock)
                    {
                        if (_replyDemuxer == null)
                        {
                            _replyDemuxer = new ReplyChannelDemuxer(bindingParameters);
                        }
                    }
                }

                typeDemuxer = _replyDemuxer;
            }
            else
            {
                lock (_thisLock)
                {
                    if (!_typeDemuxers.TryGetValue(parentType, out typeDemuxer))
                    {
                        typeDemuxer = CreateTypedDemuxer(channelType, bindingParameters);
                        _typeDemuxers.Add(channelType, typeDemuxer);
                    }
                }
            }

            //if (!createdDemuxer)
            //{
            //    context.RemainingBindingElements.Clear();
            //}

            return(typeDemuxer);
        }
예제 #2
0
        internal TypedChannelDemuxer GetTypedServiceDispatcher <TChannel>()
        {
            TypedChannelDemuxer typeDemuxer = null;
            bool createdDemuxer             = false;

            //if (typeof(TChannel) == typeof(IInputChannel))
            //{
            //    if (this.inputDemuxer == null)
            //    {
            //        if (context.CanBuildInnerChannelListener<IReplyChannel>())
            //            this.inputDemuxer = this.replyDemuxer = new ReplyChannelDemuxer(context);
            //        else
            //            this.inputDemuxer = new InputChannelDemuxer(context);
            //        createdDemuxer = true;
            //    }
            //    typeDemuxer = this.inputDemuxer;
            //}
            //else
            if (typeof(TChannel) == typeof(IReplyChannel))
            {
                if (this.replyDemuxer == null)
                {
                    this.inputDemuxer = this.replyDemuxer = new ReplyChannelDemuxer();
                    createdDemuxer    = true;
                }
                typeDemuxer = this.replyDemuxer;
            }
            //else if (!this.typeDemuxers.TryGetValue(channelType, out typeDemuxer))
            //{
            //    typeDemuxer = this.CreateTypedDemuxer(channelType, context);
            //    this.typeDemuxers.Add(channelType, typeDemuxer);
            //    createdDemuxer = true;
            //}

            //if (!createdDemuxer)
            //{
            //    context.RemainingBindingElements.Clear();
            //}

            return(typeDemuxer);
        }