AzureServiceBusEndpointAddress([NotNull] Data data, AddressType addressType) { if (data == null) throw new ArgumentNullException("data"); _data = data; _tp = TokenProvider.CreateSharedSecretTokenProvider(_data.UsernameIssuer, _data.PasswordSharedSecret); Uri sbUri = ServiceBusEnvironment.CreateServiceUri("sb", _data.Namespace, string.Empty); var mfs = new MessagingFactorySettings { TokenProvider = _tp, NetMessagingTransportSettings = { // todo: configuration setting BatchFlushInterval = 50.Milliseconds() }, OperationTimeout = 3.Seconds() }; _mff = () => MessagingFactory.Create(sbUri, mfs); _nm = new NamespaceManager(sbUri, _tp); string suffix = ""; if (addressType == AddressType.Queue) _queueDescription = new QueueDescriptionImpl(data.QueueOrTopicName); else { _topicDescription = new TopicDescriptionImpl(data.QueueOrTopicName); suffix = "?topic=true"; } _rebuiltUri = new Uri(string.Format("azure-sb://{0}:{1}@{2}/{3}{4}", data.UsernameIssuer, data.PasswordSharedSecret, data.Namespace, data.QueueOrTopicName, suffix)); _friendlyUri = new Uri(string.Format("azure-sb://{0}/{1}{2}", data.Namespace, data.QueueOrTopicName, suffix)); }
static bool TryParseInternal(Uri uri, out Data data, out IEnumerable<ValidationResult> results) { data = null; var res = new List<ValidationResult>(); if (string.IsNullOrWhiteSpace(uri.UserInfo) || !uri.UserInfo.Contains(":")) { res.Add(new ValidationResultImpl(ValidationResultDisposition.Failure, "UserInfo", "UserInfo part of uri (stuff before @-character), doesn't exist or doesn't " + "contain the :-character.")); results = res; return false; } if (uri.AbsolutePath.LastIndexOf('/') != 0) // first item must be / { res.Add(new ValidationResultImpl(ValidationResultDisposition.Failure, "Application", "AbsolutePath part of uri (stuff after hostname), contains more than one slash")); results = res; return false; } data = new Data { UsernameIssuer = uri.UserInfo.Split(':')[0], PasswordSharedSecret = uri.UserInfo.Split(':')[1], Namespace = uri.Host.Contains(".") ? uri.Host.Substring(0, uri.Host.IndexOf('.')) : uri.Host, QueueOrTopicName = uri.AbsolutePath.TrimStart('/'), AddressType = uri.PathAndQuery.Contains("topic=true") ? AddressType.Topic : AddressType.Queue }; results = null; return true; }