private TokenProvider GetTokenProvider(string connectionStringName)
        {
            var connectionString = Environment.GetEnvironmentVariable(connectionStringName, EnvironmentVariableTarget.Process);

            bool endpointAlreadyConfigured = false;

            //ignore case?
            var tokenizerRegex = new Regex("^Endpoint=(?<endpoint>.*);SharedAccessKeyName=(?<sharedAccessKeyName>.*);SharedAccessKey=(?<sharedAccessKey>.*)$");
            var match          = tokenizerRegex.Match(connectionString);

            if (!match.Success)
            {
                //throw new ConfigurationErrorsException("Connection string could not be parsed.");
                throw new Exception("Connection string could not be parsed.");
            }

            var endpointAddress     = match.Groups["endpoint"].Value;
            var sharedAccessKeyName = match.Groups["sharedAccessKeyName"].Value;
            var sharedAccessKey     = match.Groups["sharedAccessKey"].Value;

            Debug.WriteLine($"Found match endpointAddress='{endpointAddress}', sharedAccessKeyName ='{sharedAccessKeyName}', sharedAccessKey='{sharedAccessKey}'");

            //https://github.com/Particular/NServiceBus.AzureServiceBus/issues/667
            var tokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider(sharedAccessKeyName, sharedAccessKey);

            //var namespaceManager = new NamespaceManager(endpointAddress, tokenProvider);

            return(tokenProvider);
        }
コード例 #2
0
 public TokenProvider(Microsoft.Azure.ServiceBus.Primitives.TokenProvider t)
 {
     this.tokenProvider = t;
 }