Exemple #1
0
        public ServiceEndpointProvider(IOptions <ServiceOptions> options)
        {
            var connectionString = options.Value.ConnectionString;

            if (string.IsNullOrEmpty(connectionString))
            {
                throw new ArgumentException(ConnectionStringNotFound);
            }

            _accessTokenLifetime = options.Value.AccessTokenLifetime;

            string version;
            int?   port;

            (_endpoint, _accessKey, version, port) = ConnectionStringParser.Parse(connectionString);

            if (version == null || version == PreviewVersion)
            {
                _generator = new PreviewServiceEndpointGenerator(_endpoint, _accessKey);
            }
            else
            {
                _generator = new DefaultServiceEndpointGenerator(_endpoint, _accessKey, version, port);
            }
        }
        public ServiceEndpointProvider(
            ServiceEndpoint endpoint,
            ServiceOptions serviceOptions)
        {
            _accessTokenLifetime = serviceOptions.AccessTokenLifetime;
            _accessKey           = endpoint.AccessKey;
            _appName             = serviceOptions.ApplicationName;
            _algorithm           = serviceOptions.AccessTokenAlgorithm;

            Proxy = serviceOptions.Proxy;

            _generator = new DefaultServiceEndpointGenerator(endpoint);
        }
        public ServiceEndpointProvider(
            IServerNameProvider provider,
            ServiceEndpoint endpoint,
            ServiceOptions serviceOptions,
            ILoggerFactory loggerFactory = null
            )
        {
            _accessTokenLifetime = serviceOptions.AccessTokenLifetime;
            _accessKey           = endpoint.AccessKey;
            _appName             = serviceOptions.ApplicationName;
            _algorithm           = serviceOptions.AccessTokenAlgorithm;

            Proxy = serviceOptions.Proxy;

            _generator = new DefaultServiceEndpointGenerator(endpoint);

            _ = UpdateAccessKeyAsync(provider, endpoint, loggerFactory ?? NullLoggerFactory.Instance);
        }
Exemple #4
0
        public ServiceEndpointProvider(ServiceEndpoint endpoint, ServiceOptions serviceOptions)
        {
            var connectionString = endpoint.ConnectionString;

            if (string.IsNullOrEmpty(connectionString))
            {
                throw new ArgumentException(ConnectionStringNotFound);
            }

            _accessTokenLifetime = serviceOptions.AccessTokenLifetime;
            _accessKey           = endpoint.AccessKey;
            _appName             = serviceOptions.ApplicationName;
            Proxy = serviceOptions.Proxy;

            var port    = endpoint.Port;
            var version = endpoint.Version;

            _generator = new DefaultServiceEndpointGenerator(endpoint.Endpoint, _accessKey, version, port);
        }
Exemple #5
0
        public ServiceEndpointProvider(ServiceEndpoint endpoint, TimeSpan?ttl = null)
        {
            var connectionString = endpoint.ConnectionString;

            if (string.IsNullOrEmpty(connectionString))
            {
                throw new ArgumentException(ConnectionStringNotFound);
            }

            _accessTokenLifetime = ttl ?? Constants.DefaultAccessTokenLifetime;

            _endpoint  = endpoint.Endpoint;
            _accessKey = endpoint.AccessKey;

            var port    = endpoint.Port;
            var version = endpoint.Version;

            _generator = new DefaultServiceEndpointGenerator(_endpoint, _accessKey, version, port);
        }
Exemple #6
0
        public ServiceEndpointProvider(
            IServerNameProvider provider,
            ServiceEndpoint endpoint,
            ServiceOptions serviceOptions,
            ILoggerFactory loggerFactory)
        {
            _accessTokenLifetime = serviceOptions.AccessTokenLifetime;
            _accessKey           = endpoint.AccessKey;
            _appName             = serviceOptions.ApplicationName;
            _algorithm           = serviceOptions.AccessTokenAlgorithm;

            Proxy = serviceOptions.Proxy;

            _generator = new DefaultServiceEndpointGenerator(endpoint);

            if (endpoint.AccessKey is AadAccessKey key)
            {
                _ = key.UpdateAccessKeyAsync(provider, loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory)));
            }
        }