/// <summary>Wraps the given Model so that it delegates every method call to the target model but /// adapts close calls. This is useful for allowing application code to /// handle a special framework Model just like an ordinary Model.</summary> /// <param name="channelList">The channel list.</param> /// <param name="transactional">if set to <c>true</c> [transactional].</param> /// <returns>The wrapped Model</returns> protected virtual IChannelProxy GetCachedChannelProxy(LinkedList <IChannelProxy> channelList, bool transactional) { var targetChannel = this.CreateBareChannel(transactional); Logger.Debug(m => m("Creating cached Rabbit Channel from {0}", targetChannel)); this.ChannelListener.OnCreate(targetChannel, transactional); IList <Type> interfaces; if (this.publisherConfirms || this.publisherReturns) { interfaces = new List <Type> { typeof(IChannelProxy), typeof(IPublisherCallbackChannel) }; } else { interfaces = new List <Type> { typeof(IChannelProxy) }; } var handler = new CachedChannelInvocationHandler(targetChannel, channelList, transactional, this); var factory = new ProxyFactory(typeof(IChannelProxy), handler); factory.Target = handler; factory.Interfaces = interfaces.ToArray(); var channelProxy = (IChannelProxy)factory.GetProxy(); return(channelProxy); }
/// <summary>Wraps the given Model so that it delegates every method call to the target model but /// adapts close calls. This is useful for allowing application code to /// handle a special framework Model just like an ordinary Model.</summary> /// <param name="channelList">The channel list.</param> /// <param name="transactional">if set to <c>true</c> [transactional].</param> /// <returns>The wrapped Model</returns> protected virtual IChannelProxy GetCachedChannelProxy(LinkedList<IChannelProxy> channelList, bool transactional) { var targetChannel = this.CreateBareChannel(transactional); Logger.Debug(m => m("Creating cached Rabbit Channel from {0}", targetChannel)); this.ChannelListener.OnCreate(targetChannel, transactional); IList<Type> interfaces; if (this.publisherConfirms || this.publisherReturns) { interfaces = new List<Type> { typeof(IChannelProxy), typeof(IPublisherCallbackChannel) }; } else { interfaces = new List<Type> { typeof(IChannelProxy) }; } var handler = new CachedChannelInvocationHandler(targetChannel, channelList, transactional, this); var factory = new ProxyFactory(typeof(IChannelProxy), handler); factory.Target = handler; factory.Interfaces = interfaces.ToArray(); var channelProxy = (IChannelProxy)factory.GetProxy(); return channelProxy; }