public override IChannelListener <TChannel> BuildChannelListener <TChannel>(BindingContext context) { if (context == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context"); } TransportChannelListener msmqListener; MsmqTransportReceiveParameters receiveParameters = new MsmqTransportReceiveParameters(this, MsmqUri.NetMsmqAddressTranslator); if (typeof(TChannel) == typeof(IInputChannel)) { msmqListener = new MsmqInputChannelListener(this, context, receiveParameters); } else if (typeof(TChannel) == typeof(IInputSessionChannel)) { msmqListener = new MsmqInputSessionChannelListener(this, context, receiveParameters); } else { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("TChannel", SR.GetString(SR.ChannelTypeNotSupported, typeof(TChannel))); } AspNetEnvironment.Current.ApplyHostedContext(msmqListener, context); MsmqVerifier.VerifyReceiver(receiveParameters, msmqListener.Uri); return((IChannelListener <TChannel>)(object) msmqListener); }
public override IChannelListener <TChannel> BuildChannelListener <TChannel>(BindingContext context) where TChannel : class, IChannel { TransportChannelListener listener; if (context == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context"); } MsmqTransportReceiveParameters receiveParameters = new MsmqTransportReceiveParameters(this, MsmqUri.NetMsmqAddressTranslator); if (typeof(TChannel) == typeof(IInputChannel)) { listener = new MsmqInputChannelListener(this, context, receiveParameters); } else { if (typeof(TChannel) != typeof(IInputSessionChannel)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("TChannel", System.ServiceModel.SR.GetString("ChannelTypeNotSupported", new object[] { typeof(TChannel) })); } listener = new MsmqInputSessionChannelListener(this, context, receiveParameters); } AspNetEnvironment.Current.ApplyHostedContext(listener, context); MsmqVerifier.VerifyReceiver(receiveParameters, listener.Uri); return((IChannelListener <TChannel>)listener); }