@@ -74,26 +74,23 @@ namespace RabbitMQ.ServiceModel
74
74
/// </summary>
75
75
public sealed class RabbitMQTransportBindingElement : TransportBindingElement
76
76
{
77
- private Uri m_broker ;
78
- private IProtocol m_brokerProtocol ;
79
77
private ConnectionFactory m_connectionFactory ;
80
78
private IConnection m_connection ;
79
+ private bool m_hasBroker = false ;
81
80
82
81
/// <summary>
83
82
/// Creates a new instance of the RabbitMQTransportBindingElement Class using the default protocol.
84
83
/// </summary>
85
84
public RabbitMQTransportBindingElement ( )
86
85
{
87
- m_brokerProtocol = Protocols . DefaultProtocol ;
88
86
m_connectionFactory = new ConnectionFactory ( ) ;
89
- m_connection = null ;
90
87
}
91
88
92
89
private RabbitMQTransportBindingElement ( RabbitMQTransportBindingElement other )
93
90
: this ( )
94
91
{
95
- m_brokerProtocol = other . m_brokerProtocol ;
96
- m_broker = other . Broker ;
92
+ Broker = other . Broker ;
93
+ BrokerProtocol = other . BrokerProtocol ;
97
94
}
98
95
99
96
@@ -130,8 +127,7 @@ public override BindingElement Clone()
130
127
internal void EnsureConnectionAvailable ( )
131
128
{
132
129
if ( m_connection == null ) {
133
- m_connection = m_connectionFactory . CreateConnection ( BrokerProtocol , Broker . Host , Broker . Port ) ;
134
- //TODO: configure connection parameters
130
+ m_connection = m_connectionFactory . CreateConnection ( ) ;
135
131
}
136
132
}
137
133
@@ -184,8 +180,23 @@ public override string Scheme
184
180
[ ConfigurationProperty ( "broker" ) ]
185
181
public Uri Broker
186
182
{
187
- get { return m_broker ; }
188
- set { m_broker = value ; }
183
+ get
184
+ {
185
+ if ( ! m_hasBroker ) return null ;
186
+ UriBuilder build = new UriBuilder ( ) ;
187
+ build . Host = m_connectionFactory . HostName ;
188
+ build . Port = m_connectionFactory . Port ;
189
+ return build . Uri ;
190
+ }
191
+ set
192
+ {
193
+ if ( value == null ) m_hasBroker = false ;
194
+ else
195
+ {
196
+ m_connectionFactory . HostName = value . Host ;
197
+ m_connectionFactory . Port = value . Port ;
198
+ }
199
+ }
189
200
}
190
201
191
202
/// <summary>
@@ -194,8 +205,8 @@ public Uri Broker
194
205
/// </summary>
195
206
public IProtocol BrokerProtocol
196
207
{
197
- get { return m_brokerProtocol ; }
198
- set { m_brokerProtocol = value ; }
208
+ get { return m_connectionFactory . Protocol ; }
209
+ set { m_connectionFactory . Protocol = value ; }
199
210
}
200
211
201
212
public ConnectionFactory ConnectionFactory
0 commit comments