|
6 | 6 | namespace CoreHelpers.Branding.Stores.AzureStorage |
7 | 7 | { |
8 | 8 | public static class IServiceCollectionExtensions |
9 | | - { |
| 9 | + { |
10 | 10 | public static IServiceCollection AddBrandingServices4AzureStorage(this IServiceCollection services, string connectionString, string container) |
11 | 11 | { |
12 | | - services.AddScoped<IBrandingStore>((serviceProvider) => new AzureStorageBrandingStore(connectionString, container)); |
| 12 | + return services.AddBrandingServices4AzureStorage(connectionString, container, true); |
| 13 | + } |
| 14 | + |
| 15 | + public static IServiceCollection AddBrandingServices4AzureStorage(this IServiceCollection services, string connectionString, string container, bool scoped) |
| 16 | + { |
| 17 | + if (scoped) |
| 18 | + { |
| 19 | + services.AddScoped<IBrandingStore>((serviceProvider) => new AzureStorageBrandingStore(connectionString, container)); |
| 20 | + } |
| 21 | + else |
| 22 | + { |
| 23 | + services.AddTransient<IBrandingStore>((serviceProvider) => new AzureStorageBrandingStore(connectionString, container)); |
| 24 | + } |
| 25 | + |
13 | 26 | return services; |
14 | 27 | } |
15 | 28 |
|
16 | 29 | public static IServiceCollection AddBrandingServices4AzureStorage(this IServiceCollection services, IConfiguration configuration) |
| 30 | + { |
| 31 | + return services.AddBrandingServices4AzureStorage(configuration, true); |
| 32 | + } |
| 33 | + |
| 34 | + public static IServiceCollection AddBrandingServices4AzureStorage(this IServiceCollection services, IConfiguration configuration, bool scoped) |
17 | 35 | { |
18 | 36 | // search the configuration |
19 | 37 | var connectionString = configuration.GetValue<string>("Branding:Stores:AzureStorage:ConnectionString"); |
20 | 38 | var container = configuration.GetValue<string>("Branding:Stores:AzureStorage:Container"); |
21 | 39 |
|
22 | 40 | // setup |
23 | | - return services.AddBrandingServices4AzureStorage(connectionString, container); |
| 41 | + return services.AddBrandingServices4AzureStorage(connectionString, container, scoped); |
24 | 42 | } |
25 | 43 | } |
26 | 44 | } |
|
0 commit comments