summaryrefslogtreecommitdiff
path: root/dotnet/Qpid.Client/Client/QpidConnectionInfo.cs
diff options
context:
space:
mode:
authorTomas Restrepo <tomasr@apache.org>2007-05-18 00:51:12 +0000
committerTomas Restrepo <tomasr@apache.org>2007-05-18 00:51:12 +0000
commitdbe349500e458cdf38cd4e561d27c9fa24dff7ca (patch)
tree2390c50d9a0d31506b6e9007ab7dfed5bb51ad16 /dotnet/Qpid.Client/Client/QpidConnectionInfo.cs
parentee94c939a9d77f0de6ae0cb33c782a9015bb8452 (diff)
downloadqpid-python-dbe349500e458cdf38cd4e561d27c9fa24dff7ca.tar.gz
Merged revisions 537954-538078,538080-538083,538085-538097,538099-538108,538110-538239,538241-538881,538883-538906,538908-538911,538913-538921,538923-539191 via svnmerge from
https://svn.apache.org/repos/asf/incubator/qpid/branches/M2 ........ r537954 | tomasr | 2007-05-14 14:10:59 -0500 (Mon, 14 May 2007) | 4 lines * QPID-487 (Contributed by Carlos Medina) Fix QpidConnectionInfo.ToString() * QPID-485 (Contributed by Carlos Medina) Fix AmqBrokerInfo.Equals() * QPID-456 Enforce virtual host names start with '/' ........ r538035 | tomasr | 2007-05-14 20:33:00 -0500 (Mon, 14 May 2007) | 6 lines * QPID-452 Improve message classes API * Add XML documentation to IChannel and IMessage * Add missing BrokerDetailTests * Add new tests for message creation and message factories * Fix wrong default encoding for text messages ........ r539178 | tomasr | 2007-05-17 18:50:50 -0500 (Thu, 17 May 2007) | 6 lines * QPID-492 Fix Race condition in message decoding * QPID-249 Make ServiceRequestingClient and ServiceProvidingClient a single, self contained test * Fix incorrect exception message in Qpid.Buffers, improve tests * Make ContentBody use an sliced buffer to avoid extra data copy * Remove useless tests in Qpid.Client (Blocking IO tests) ........ r539191 | tomasr | 2007-05-17 19:18:26 -0500 (Thu, 17 May 2007) | 1 line QPID-490 (Contributed by Carlos Medina) Implement PurgeQueue and DeleteQueue ........ git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@539198 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'dotnet/Qpid.Client/Client/QpidConnectionInfo.cs')
-rw-r--r--dotnet/Qpid.Client/Client/QpidConnectionInfo.cs66
1 files changed, 50 insertions, 16 deletions
diff --git a/dotnet/Qpid.Client/Client/QpidConnectionInfo.cs b/dotnet/Qpid.Client/Client/QpidConnectionInfo.cs
index 914170467a..d88683f7d5 100644
--- a/dotnet/Qpid.Client/Client/QpidConnectionInfo.cs
+++ b/dotnet/Qpid.Client/Client/QpidConnectionInfo.cs
@@ -171,19 +171,10 @@ namespace Qpid.Client
sb.Append('?');
foreach (String key in options.Keys)
{
- sb.Append(key);
-
- sb.Append("='");
-
- sb.Append(options[key]);
-
- sb.Append("'");
- sb.Append(DEFAULT_OPTION_SEPERATOR);
+ sb.AppendFormat("{0}='{1}'{2}", key, options[key], DEFAULT_OPTION_SEPERATOR);
}
sb.Remove(sb.Length - 1, 1);
- // sb.deleteCharAt(sb.length() - 1);
-
return sb.ToString();
}
}
@@ -358,9 +349,10 @@ namespace Qpid.Client
public class QpidConnectionInfo : IConnectionInfo
{
+ const string DEFAULT_VHOST = "/";
string _username = "guest";
string _password = "guest";
- string _virtualHost = "/";
+ string _virtualHost = DEFAULT_VHOST;
string _failoverMethod = null;
IDictionary _failoverOptions = new Hashtable();
@@ -385,15 +377,51 @@ namespace Qpid.Client
public string AsUrl()
{
- string result = "amqp://";
- foreach (IBrokerInfo info in _brokerInfos)
+ StringBuilder sb = new StringBuilder();
+ sb.AppendFormat("{0}://", ConnectionUrlConstants.AMQ_PROTOCOL);
+
+ if (_username != null)
{
- result += info.ToString();
+ sb.Append(_username);
+ if (_password != null)
+ {
+ sb.AppendFormat(":{0}", _password);
+ }
+ sb.Append("@");
}
- return result;
+ sb.Append(_clientName);
+ sb.Append(_virtualHost);
+ sb.Append(OptionsToString());
+
+ return sb.ToString();
}
+ private String OptionsToString()
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.AppendFormat("?{0}='", ConnectionUrlConstants.OPTIONS_BROKERLIST);
+
+ foreach (IBrokerInfo broker in _brokerInfos)
+ {
+ sb.AppendFormat("{0};", broker);
+ }
+
+ sb.Remove(sb.Length - 1, 1);
+ sb.Append("'");
+
+ if (_failoverMethod != null)
+ {
+ sb.AppendFormat("{0}{1}='{2}{3}'", URLHelper.DEFAULT_OPTION_SEPERATOR,
+ ConnectionUrlConstants.OPTIONS_FAILOVER,
+ _failoverMethod,
+ URLHelper.printOptions((Hashtable)_failoverOptions));
+ }
+
+ return sb.ToString();
+ }
+
+
public string FailoverMethod
{
get { return _failoverMethod; }
@@ -449,7 +477,13 @@ namespace Qpid.Client
public string VirtualHost
{
get { return _virtualHost; }
- set { _virtualHost = value; }
+ set {
+ _virtualHost = value;
+ if ( _virtualHost == null || _virtualHost.Length == 0 )
+ _virtualHost = DEFAULT_VHOST;
+ if ( _virtualHost[0] != '/' )
+ _virtualHost = '/' + _virtualHost;
+ }
}
public string GetOption(string key)