Skip to content

Commit 512e34e

Browse files
author
David R. MacIver
committed
WCF code now compiles successfully. If I've followed the logic correctly there should be no behavioural changes, but I haven't the foggiest idea how to test it
1 parent 90332e1 commit 512e34e

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

projects/wcf/RabbitMQ.ServiceModel/src/serviceModel/RabbitMQTransportBindingElement.cs

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,26 +74,23 @@ namespace RabbitMQ.ServiceModel
7474
/// </summary>
7575
public sealed class RabbitMQTransportBindingElement : TransportBindingElement
7676
{
77-
private Uri m_broker;
78-
private IProtocol m_brokerProtocol;
7977
private ConnectionFactory m_connectionFactory;
8078
private IConnection m_connection;
79+
private bool m_hasBroker = false;
8180

8281
/// <summary>
8382
/// Creates a new instance of the RabbitMQTransportBindingElement Class using the default protocol.
8483
/// </summary>
8584
public RabbitMQTransportBindingElement()
8685
{
87-
m_brokerProtocol = Protocols.DefaultProtocol;
8886
m_connectionFactory = new ConnectionFactory();
89-
m_connection = null;
9087
}
9188

9289
private RabbitMQTransportBindingElement(RabbitMQTransportBindingElement other)
9390
: this()
9491
{
95-
m_brokerProtocol = other.m_brokerProtocol;
96-
m_broker = other.Broker;
92+
Broker = other.Broker;
93+
BrokerProtocol = other.BrokerProtocol;
9794
}
9895

9996

@@ -130,8 +127,7 @@ public override BindingElement Clone()
130127
internal void EnsureConnectionAvailable()
131128
{
132129
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();
135131
}
136132
}
137133

@@ -184,8 +180,23 @@ public override string Scheme
184180
[ConfigurationProperty("broker")]
185181
public Uri Broker
186182
{
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+
}
189200
}
190201

191202
/// <summary>
@@ -194,8 +205,8 @@ public Uri Broker
194205
/// </summary>
195206
public IProtocol BrokerProtocol
196207
{
197-
get { return m_brokerProtocol; }
198-
set { m_brokerProtocol = value; }
208+
get { return m_connectionFactory.Protocol; }
209+
set { m_connectionFactory.Protocol = value; }
199210
}
200211

201212
public ConnectionFactory ConnectionFactory

0 commit comments

Comments
 (0)