public static IServiceCollection AddStorageManager(this IServiceCollection services, StorageOptions options, IHealthChecksBuilder healthChecksBuilder = null) { if (options.UsedAzure()) { services.AddAzureBlobStorageManager(options.Azure); if (healthChecksBuilder != null) { healthChecksBuilder.AddAzureBlobStorage( options.Azure.ConnectionString, containerName: options.Azure.Container, name: "Storage (Azure Blob)", failureStatus: HealthStatus.Degraded); } } else if (options.UsedAmazon()) { services.AddAmazonS3StorageManager(options.Amazon); if (healthChecksBuilder != null) { healthChecksBuilder.AddS3( s3 => { s3.AccessKey = options.Amazon.AccessKeyID; s3.SecretKey = options.Amazon.SecretAccessKey; s3.BucketName = options.Amazon.BucketName; s3.S3Config = new AmazonS3Config { RegionEndpoint = RegionEndpoint.GetBySystemName(options.Amazon.RegionEndpoint), }; }, name: "Storage (Amazon S3)", failureStatus: HealthStatus.Degraded); } } else if (options.UsedLocal()) { services.AddLocalStorageManager(options.Local); if (healthChecksBuilder != null) { healthChecksBuilder.AddFilePathWrite(options.Local.Path, name: "Storage (Local Directory)", failureStatus: HealthStatus.Degraded); } } else { services.AddFakeStorageManager(); } return(services); }