protected virtual void Initialize(ResourceStorageConfig config) { _config = config; TableClient = Microsoft.Azure.Cosmos.Table.CloudStorageAccount.Parse(_config.StorageConnectionString).CreateCloudTableClient(); TableClient.DefaultRequestOptions.PayloadFormat = TablePayloadFormat.Json; ApiResourceTableName = config.ApiTableName; if (string.IsNullOrWhiteSpace(ApiResourceTableName)) { throw new ArgumentException($"ApiResourceTableName cannot be null or empty, check your configuration.", nameof(config.ApiTableName)); } ApiResourceTable = TableClient.GetTableReference(ApiResourceTableName); BlobClient = Microsoft.Azure.Storage.CloudStorageAccount.Parse(_config.StorageConnectionString).CreateCloudBlobClient(); ApiBlobContainerName = config.ApiBlobContainerName; if (string.IsNullOrWhiteSpace(ApiBlobContainerName)) { throw new ArgumentException($"ApiBlobContainerName cannot be null or empty, check your configuration.", nameof(config.ApiBlobContainerName)); } ApiResourceBlobContainer = BlobClient.GetContainerReference(ApiBlobContainerName); IdentityBlobContainerName = config.IdentityBlobContainerName; if (string.IsNullOrWhiteSpace(IdentityBlobContainerName)) { throw new ArgumentException($"IdentityBlobContainerName cannot be null or empty, check your configuration.", nameof(config.IdentityBlobContainerName)); } IdentityResourceBlobContainer = BlobClient.GetContainerReference(IdentityBlobContainerName); }
public ResourceStorageContext(ResourceStorageConfig config) { if (config == null) { throw new ArgumentNullException(nameof(config)); } Initialize(config); }
/// <summary> /// Constructor for cache refresh. /// </summary> /// <param name="serviceProvider"></param> /// <param name="logger"></param> /// <param name="options"></param> public ResourceCacheRefresh(IServiceProvider serviceProvider, ILogger <ResourceCacheRefresh> logger, IOptions <ResourceStorageConfig> 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)); }
public ResourceStorageController(ResourceStorageMaster resourceStorageMaster, ResourceStorageConfig resourceStorageConfig, ResourceStorageData resourceStorageData) { this.resourceStorageMaster = resourceStorageMaster; this.resourceStorageConfig = resourceStorageConfig; this.resourceStorageData = resourceStorageData; }
public ResourceCacheRefreshHost(ResourceCacheRefresh cacheRefresh, IOptions <ResourceStorageConfig> config) { _cacheRefresh = cacheRefresh; _config = config.Value; }