Пример #1
0
        public override IChannelListener <TChannel> BuildChannelListener <TChannel>(BindingContext context) where TChannel : class, IChannel
        {
            if (context == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
            }
            this.VerifyTransportMode(context);
            this.SetSecuritySettings(context);
            IMessageFilterTable <EndpointAddress> table = context.BindingParameters.Find <IMessageFilterTable <EndpointAddress> >();

            InternalDuplexBindingElement.AddDuplexListenerSupport(context, ref this.internalDuplexBindingElement);
            if (typeof(TChannel) == typeof(IInputSessionChannel))
            {
                ReliableChannelListenerBase <IInputSessionChannel> base2 = null;
                if (context.CanBuildInnerChannelListener <IReplySessionChannel>())
                {
                    base2 = new ReliableInputListenerOverReplySession(this, context);
                }
                else if (context.CanBuildInnerChannelListener <IReplyChannel>())
                {
                    base2 = new ReliableInputListenerOverReply(this, context);
                }
                else if (context.CanBuildInnerChannelListener <IDuplexSessionChannel>())
                {
                    base2 = new ReliableInputListenerOverDuplexSession(this, context);
                }
                else if (context.CanBuildInnerChannelListener <IDuplexChannel>())
                {
                    base2 = new ReliableInputListenerOverDuplex(this, context);
                }
                if (base2 != null)
                {
                    base2.LocalAddresses = table;
                    return((IChannelListener <TChannel>)base2);
                }
            }
            else if (typeof(TChannel) == typeof(IDuplexSessionChannel))
            {
                ReliableChannelListenerBase <IDuplexSessionChannel> base3 = null;
                if (context.CanBuildInnerChannelListener <IDuplexSessionChannel>())
                {
                    base3 = new ReliableDuplexListenerOverDuplexSession(this, context);
                }
                else if (context.CanBuildInnerChannelListener <IDuplexChannel>())
                {
                    base3 = new ReliableDuplexListenerOverDuplex(this, context);
                }
                if (base3 != null)
                {
                    base3.LocalAddresses = table;
                    return((IChannelListener <TChannel>)base3);
                }
            }
            else if (typeof(TChannel) == typeof(IReplySessionChannel))
            {
                ReliableChannelListenerBase <IReplySessionChannel> base4 = null;
                if (context.CanBuildInnerChannelListener <IReplySessionChannel>())
                {
                    base4 = new ReliableReplyListenerOverReplySession(this, context);
                }
                else if (context.CanBuildInnerChannelListener <IReplyChannel>())
                {
                    base4 = new ReliableReplyListenerOverReply(this, context);
                }
                if (base4 != null)
                {
                    base4.LocalAddresses = table;
                    return((IChannelListener <TChannel>)base4);
                }
            }
            throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("TChannel", System.ServiceModel.SR.GetString("ChannelTypeNotSupported", new object[] { typeof(TChannel) }));
        }
        public override IChannelListener <TChannel> BuildChannelListener <TChannel>(BindingContext context)
        {
            if (context == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
            }

            this.VerifyTransportMode(context);
            this.SetSecuritySettings(context);

#pragma warning suppress 56506 // BindingContext guarantees BindingParameters is never null.
            IMessageFilterTable <EndpointAddress> table = context.BindingParameters.Find <IMessageFilterTable <EndpointAddress> >();

            InternalDuplexBindingElement.AddDuplexListenerSupport(context, ref this.internalDuplexBindingElement);

            if (typeof(TChannel) == typeof(IInputSessionChannel))
            {
                ReliableChannelListenerBase <IInputSessionChannel> listener = null;

                if (context.CanBuildInnerChannelListener <IReplySessionChannel>())
                {
                    listener = new ReliableInputListenerOverReplySession(this, context);
                }
                else if (context.CanBuildInnerChannelListener <IReplyChannel>())
                {
                    listener = new ReliableInputListenerOverReply(this, context);
                }
                else if (context.CanBuildInnerChannelListener <IDuplexSessionChannel>())
                {
                    listener = new ReliableInputListenerOverDuplexSession(this, context);
                }
                else if (context.CanBuildInnerChannelListener <IDuplexChannel>())
                {
                    listener = new ReliableInputListenerOverDuplex(this, context);
                }

                if (listener != null)
                {
                    listener.LocalAddresses = table;
                    return((IChannelListener <TChannel>)(object) listener);
                }
            }
            else if (typeof(TChannel) == typeof(IDuplexSessionChannel))
            {
                ReliableChannelListenerBase <IDuplexSessionChannel> listener = null;

                if (context.CanBuildInnerChannelListener <IDuplexSessionChannel>())
                {
                    listener = new ReliableDuplexListenerOverDuplexSession(this, context);
                }
                else if (context.CanBuildInnerChannelListener <IDuplexChannel>())
                {
                    listener = new ReliableDuplexListenerOverDuplex(this, context);
                }

                if (listener != null)
                {
                    listener.LocalAddresses = table;
                    return((IChannelListener <TChannel>)(object) listener);
                }
            }
            else if (typeof(TChannel) == typeof(IReplySessionChannel))
            {
                ReliableChannelListenerBase <IReplySessionChannel> listener = null;

                if (context.CanBuildInnerChannelListener <IReplySessionChannel>())
                {
                    listener = new ReliableReplyListenerOverReplySession(this, context);
                }
                else if (context.CanBuildInnerChannelListener <IReplyChannel>())
                {
                    listener = new ReliableReplyListenerOverReply(this, context);
                }

                if (listener != null)
                {
                    listener.LocalAddresses = table;
                    return((IChannelListener <TChannel>)(object) listener);
                }
            }

            throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("TChannel", SR.GetString(SR.ChannelTypeNotSupported, typeof(TChannel)));
        }