1234567891011121314151617181920212223242526272829303132 |
- using Microsoft.Extensions.DependencyInjection;
- using Microsoft.Extensions.DependencyInjection.Extensions;
- using System;
- using System.Collections.Generic;
- using System.Text;
- using TEAMModelOS.SDK.DI;
- namespace TEAMModelOS.SDK.DI.Multiple
- {
- public static class MultipleAzureStorageFactoryExtensions
- {
- /// <summary>
- /// Storage依赖注入
- /// </summary>
- /// <param name="services"></param>
- /// <param name="connectionInfo"></param>
- /// <returns></returns>
- /// <exception cref="ArgumentNullException"></exception>
- public static IServiceCollection AddMultipleAzureStorage(this IServiceCollection services, List<(string name, string connectionString)> connectionInfo)
- {
- if (services == null) throw new ArgumentNullException(nameof(services));
- if (connectionInfo == null) throw new ArgumentNullException(nameof(connectionInfo));
- services.TryAddSingleton<AzureStorageFactory>();
- connectionInfo.ForEach(connection =>
- {
- services.Configure<AzureStorageFactoryOptions>(connection.name, o => { o.Name = connection.name; o.StorageAccountConnectionString = connection.connectionString; });
- });
- return services;
- }
- }
- }
|