| | | 1 | | using System; |
| | | 2 | | using System.ServiceModel.Channels; |
| | | 3 | | using RabbitMQ.Client; |
| | | 4 | | |
| | | 5 | | namespace CoreWCF.ServiceModel.Channels |
| | | 6 | | { |
| | | 7 | | public class RabbitMqTransportBindingElement : TransportBindingElement |
| | | 8 | | { |
| | 3 | 9 | | public RabbitMqTransportBindingElement() |
| | 3 | 10 | | { } |
| | | 11 | | |
| | | 12 | | private RabbitMqTransportBindingElement(RabbitMqTransportBindingElement other) |
| | 15 | 13 | | : base(other) |
| | | 14 | | { |
| | 15 | 15 | | MaxReceivedMessageSize = other.MaxReceivedMessageSize; |
| | 15 | 16 | | BrokerProtocol = other.BrokerProtocol; |
| | 15 | 17 | | SslOption = other.SslOption; |
| | 15 | 18 | | VirtualHost = other.VirtualHost; |
| | 15 | 19 | | } |
| | | 20 | | |
| | | 21 | | /// <summary> |
| | | 22 | | /// Gets the scheme used by the binding, soap.amqp |
| | | 23 | | /// </summary> |
| | | 24 | | public override string Scheme |
| | | 25 | | { |
| | 9 | 26 | | get { return RabbitMqDefaults.Scheme; } |
| | | 27 | | } |
| | | 28 | | |
| | | 29 | | /// <summary> |
| | | 30 | | /// Specifies the version of the AMQP protocol that should be used to |
| | | 31 | | /// communicate with the broker |
| | | 32 | | /// </summary> |
| | 48 | 33 | | public IProtocol BrokerProtocol { get; set; } = Protocols.DefaultProtocol; |
| | | 34 | | |
| | | 35 | | /// <summary> |
| | | 36 | | /// SSL configuration for the RabbitMQ queue |
| | | 37 | | /// </summary> |
| | 36 | 38 | | public SslOption SslOption { get; set; } |
| | | 39 | | |
| | | 40 | | /// <summary> |
| | | 41 | | /// Virtual host for the RabbitMQ queue |
| | | 42 | | /// </summary> |
| | 36 | 43 | | public string VirtualHost { get; set; } |
| | | 44 | | |
| | | 45 | | public override BindingElement Clone() |
| | | 46 | | { |
| | 15 | 47 | | return new RabbitMqTransportBindingElement(this); |
| | | 48 | | } |
| | | 49 | | |
| | | 50 | | public override T GetProperty<T>(BindingContext context) |
| | | 51 | | { |
| | 9 | 52 | | if (context == null) |
| | | 53 | | { |
| | 0 | 54 | | throw new ArgumentNullException(nameof(context)); |
| | | 55 | | } |
| | | 56 | | |
| | 9 | 57 | | return context.GetInnerProperty<T>(); |
| | | 58 | | } |
| | | 59 | | |
| | | 60 | | public override IChannelFactory<TChannel> BuildChannelFactory<TChannel>(BindingContext context) |
| | | 61 | | { |
| | 3 | 62 | | if (context == null) |
| | | 63 | | { |
| | 0 | 64 | | throw new ArgumentNullException(nameof(context)); |
| | | 65 | | } |
| | | 66 | | |
| | 3 | 67 | | return (IChannelFactory<TChannel>)new RabbitMqChannelFactory(this, context); |
| | | 68 | | } |
| | | 69 | | |
| | | 70 | | /// <summary> |
| | | 71 | | /// Used by higher layers to determine what types of channel factories this |
| | | 72 | | /// binding element supports. Which in this case is just IOutputChannel. |
| | | 73 | | /// </summary> |
| | | 74 | | public override bool CanBuildChannelFactory<TChannel>(BindingContext context) |
| | | 75 | | { |
| | 3 | 76 | | return typeof(TChannel) == typeof(IOutputChannel); |
| | | 77 | | } |
| | | 78 | | } |
| | | 79 | | } |