Beispiel #1
0
 public ClientStorageContext(ClientStorageConfig config)
 {
     if (config == null)
     {
         throw new ArgumentNullException(nameof(config));
     }
     Initialize(config);
 }
Beispiel #2
0
        /// <summary>
        /// Constructor for cache refresh.
        /// </summary>
        /// <param name="serviceProvider"></param>
        /// <param name="logger"></param>
        /// <param name="options"></param>
        public ClientCacheRefresh(IServiceProvider serviceProvider, ILogger <ClientCacheRefresh> logger, IOptions <ClientStorageConfig> config)
        {
            _config = config?.Value ?? throw new ArgumentNullException(nameof(config));
            if (_config.CacheRefreshInterval < 1)
            {
                throw new ArgumentException("Cache refresh interval must be at least 1 second");
            }

            _logger          = logger ?? throw new ArgumentNullException(nameof(logger));
            _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));
        }
        protected virtual void Initialize(ClientStorageConfig config)
        {
            _config = config;


            BlobClient        = Microsoft.Azure.Storage.CloudStorageAccount.Parse(_config.StorageConnectionString).CreateCloudBlobClient();
            BlobContainerName = config.BlobContainerName;
            if (string.IsNullOrWhiteSpace(BlobContainerName))
            {
                throw new ArgumentException($"BlobContainerName cannot be null or empty, check your configuration.", nameof(config.BlobContainerName));
            }
            ClientBlobContainer = BlobClient.GetContainerReference(BlobContainerName);
        }
Beispiel #4
0
        protected virtual void Initialize(ClientStorageConfig config)
        {
            _config = config;


            BlobClient        = new BlobServiceClient(_config.StorageConnectionString);
            BlobContainerName = config.BlobContainerName;
            if (string.IsNullOrWhiteSpace(BlobContainerName))
            {
                throw new ArgumentException($"BlobContainerName cannot be null or empty, check your configuration.", nameof(config.BlobContainerName));
            }
            ClientBlobContainer      = BlobClient.GetBlobContainerClient(BlobContainerName);
            BlobCacheContainerName   = !string.IsNullOrWhiteSpace(config.BlobCacheContainerName) ? config.BlobCacheContainerName : DefaultClientCacheBlobContainer;
            ClientCacheBlobContainer = BlobClient.GetBlobContainerClient(BlobCacheContainerName);
        }
 public ClientCacheRefreshHost(ClientCacheRefresh cacheRefresh, IOptions <ClientStorageConfig> config)
 {
     _cacheRefresh = cacheRefresh;
     _config       = config.Value;
 }