diff --git a/src/Exceptionless.Insulation/Bootstrapper.cs b/src/Exceptionless.Insulation/Bootstrapper.cs index fc12ca30c..d47c6916b 100644 --- a/src/Exceptionless.Insulation/Bootstrapper.cs +++ b/src/Exceptionless.Insulation/Bootstrapper.cs @@ -185,40 +185,24 @@ private static void RegisterStorage(IServiceCollection container, StorageOptions { if (String.Equals(options.Provider, "azurestorage")) { - container.ReplaceSingleton(s => + container.ReplaceSingleton(s => new AzureFileStorage(new AzureFileStorageOptions { - IFileStorage storage = new AzureFileStorage(new AzureFileStorageOptions - { - ConnectionString = options.ConnectionString, - ContainerName = "ex-events", - Serializer = s.GetRequiredService(), - TimeProvider = s.GetRequiredService(), - LoggerFactory = s.GetRequiredService() - }); - - if (!String.IsNullOrWhiteSpace(options.Scope)) - storage = new ScopedFileStorage(storage, options.Scope); - - return storage; - }); + ConnectionString = options.ConnectionString, + ContainerName = $"{options.ScopePrefix}ex-events", + Serializer = s.GetRequiredService(), + TimeProvider = s.GetRequiredService(), + LoggerFactory = s.GetRequiredService() + })); } else if (String.Equals(options.Provider, "aliyun")) { - container.ReplaceSingleton(s => + container.ReplaceSingleton(s => new AliyunFileStorage(new AliyunFileStorageOptions { - IFileStorage storage = new AliyunFileStorage(new AliyunFileStorageOptions - { - ConnectionString = options.ConnectionString, - Serializer = s.GetRequiredService(), - TimeProvider = s.GetRequiredService(), - LoggerFactory = s.GetRequiredService() - }); - - if (!String.IsNullOrWhiteSpace(options.Scope)) - storage = new ScopedFileStorage(storage, options.Scope); - - return storage; - }); + ConnectionString = options.ConnectionString, + Serializer = s.GetRequiredService(), + TimeProvider = s.GetRequiredService(), + LoggerFactory = s.GetRequiredService() + })); } else if (String.Equals(options.Provider, "folder")) { @@ -241,40 +225,24 @@ private static void RegisterStorage(IServiceCollection container, StorageOptions } else if (String.Equals(options.Provider, "minio")) { - container.ReplaceSingleton(s => + container.ReplaceSingleton(s => new MinioFileStorage(new MinioFileStorageOptions { - IFileStorage storage = new MinioFileStorage(new MinioFileStorageOptions - { - ConnectionString = options.ConnectionString, - Serializer = s.GetRequiredService(), - TimeProvider = s.GetRequiredService(), - LoggerFactory = s.GetRequiredService() - }); - - if (!String.IsNullOrWhiteSpace(options.Scope)) - storage = new ScopedFileStorage(storage, options.Scope); - - return storage; - }); + ConnectionString = options.ConnectionString, + Serializer = s.GetRequiredService(), + TimeProvider = s.GetRequiredService(), + LoggerFactory = s.GetRequiredService() + })); } else if (String.Equals(options.Provider, "s3")) { - container.ReplaceSingleton(s => - { - IFileStorage storage = new S3FileStorage(o => o + container.ReplaceSingleton(s => new S3FileStorage(o => o .ConnectionString(options.ConnectionString) .Credentials(GetAWSCredentials(options.Data)) .Region(GetAWSRegionEndpoint(options.Data)) - .Bucket(options.Data.GetString("bucket", "ex-events")) + .Bucket(options.Data.GetString("bucket", $"{options.ScopePrefix}ex-events")) .Serializer(s.GetRequiredService()) .TimeProvider(s.GetRequiredService()) - .LoggerFactory(s.GetRequiredService())); - - if (!String.IsNullOrWhiteSpace(options.Scope)) - storage = new ScopedFileStorage(storage, options.Scope); - - return storage; - }); + .LoggerFactory(s.GetRequiredService()))); } }