StorageServiceCollectionExtensions

We found 10 examples in language CSharp for this search. You will see 14 fragments of code.
        public static IServiceCollection AddStorageServices(this IServiceCollection services)
        {
            var serviceProvider = services.BuildServiceProvider();

            var storageConfiguration = serviceProvider.GetRequiredService<IStorageServiceConfiguration>();

            services.TryAddSingleton(implementationFactory =>
            {
                BlobServiceClient blobServiceClient = new BlobServiceClient(storageConfiguration.ConnectionString);
                return blobServiceClient;
            });

            return services;
        }

        public static IServiceCollection AddStorageServices(this IServiceCollection services)
        {
            var serviceProvider = services.BuildServiceProvider();

            var storageConfiguration = serviceProvider.GetRequiredService<IBlobStorageServiceConfiguration>();

            services.AddSingleton(factory => new BlobServiceClient(storageConfiguration.ConnectionString));
            services.AddSingleton<IBlobStorageService, BlobStorageService>();
            return services;
        }

        public static IServiceCollection AddStorageServices(this IServiceCollection services)
        {
            var serviceProvider = services.BuildServiceProvider();

            var storageConfiguration = serviceProvider.GetRequiredService<IBlobStorageServiceConfiguration>();

            services.AddSingleton(factory => new BlobServiceClient(storageConfiguration.ConnectionString));
            services.AddSingleton<IBlobStorageService, BlobStorageService>();
            return services;
        }

        public static IServiceCollection AddStorage(this IServiceCollection services)
        {
            services.AddSingleton<StorageManager>();
            services.AddSingleton<IFileStorage, BlobFileStorage>();
            return services;
        }

        public static IServiceCollection AddExplorerSpanStorage(
            this IServiceCollection services,
            Action<ISpanStorageBuilder> configure)
        {
            if (services == null) throw new ArgumentNullException(nameof(services));

            services.AddSingleton<ISpanProcessor, SpanProcessor>();

            configure(new SpanStorageBuilder(services));

            return services;
        }
        
        public static IServiceCollection AddExplorerDependencyStorage(
            this IServiceCollection services,
            Action<IDependencyStorageBuilder> configure)
        {
            if (services == null) throw new ArgumentNullException(nameof(services));

            configure(new DependencyStorageBuilder(services));

            return services;
        }

        /// <summary>
        /// Add Local File Storage to DI registration.
        /// </summary>
        public static IServiceCollection AddFileStorage(
            this IServiceCollection services,
            string sectionName = " StorageProviders:FileStorage",
            Action<FileSystemBlobStorageOptions, IServiceProvider>? configureOptions = default)
        {
            services
                .AddChangeTokenOptions<FileSystemBlobStorageOptions>(
                    sectionName: sectionName,
                    configureAction: (opt, sp) => configureOptions?.Invoke(opt, sp));

            services.AddScoped<IBlobContainer, FileSystemBlobStorage>();
            services.AddScoped<IBlobStorage, FileSystemBlobStorage>();

            return services;
        }

        /// <summary>
        /// Add Memory File Storage to DI registration.
        /// </summary>
        /// <param name="services"></param>
        /// <param name="sectionName"></param>
        /// <param name="configureOptions"></param>
        /// <returns></returns>
        public static IServiceCollection AddMemoryStorage(
            this IServiceCollection services,
            string sectionName = " StorageProviders:MemoryStorage",
            Action<InMemoryBlobStorageOptions, IServiceProvider>? configureOptions = default)
        {
            services
                .AddChangeTokenOptions<InMemoryBlobStorageOptions>(
                    sectionName: sectionName,
                    configureAction: (opt, sp) => configureOptions?.Invoke(opt, sp));

            services.AddScoped<IBlobContainer, FileSystemBlobStorage>();
            services.AddScoped<IBlobStorage, FileSystemBlobStorage>();

            return services;
        }

        public static IServiceCollection AddStorage(this IServiceCollection services)
        {
            services.TryAddTransient<IStorageFactory, Internal.StorageFactory>();
            services.TryAdd(ServiceDescriptor.Transient(typeof(IStore<>), typeof(Internal.GenericStoreProxy<>)));
            return services;
        }

        public static IServiceCollection AddStorage(this IServiceCollection services, IConfigurationSection configurationSection)
        {
            return services
                .Configure<StorageOptions>(configurationSection)
                .AddStorage();
        }

        public static IServiceCollection AddStorage(this IServiceCollection services, IConfigurationRoot configurationRoot)
        {
            return services
                .Configure<StorageOptions>(configurationRoot.GetSection(StorageOptions.DefaultConfigurationSectionName))
                .Configure<StorageOptions>(storageOptions =>
                {
                    var connectionStrings = new Dictionary<string, string>();
                    ConfigurationBinder.Bind(configurationRoot.GetSection("ConnectionStrings"), connectionStrings);

                    if (storageOptions.ConnectionStrings != null)
                    {
                        foreach (var existingConnectionString in storageOptions.ConnectionStrings)
                        {
                            connectionStrings[existingConnectionString.Key] = existingConnectionString.Value;
                        }
                    }

                    storageOptions.ConnectionStrings = connectionStrings;
                })
                .AddStorage();
        }

        public static IServiceCollection AddStorageServices(this IServiceCollection services)
        {
            var serviceProvider = services.BuildServiceProvider();

            var storageConfiguration = serviceProvider.GetRequiredService<IStorageServiceConfiguration>();

            services.TryAddSingleton(implementationFactory =>
            {
                BlobServiceClient blobServiceClient = new BlobServiceClient(storageConfiguration.ConnectionString);
                return blobServiceClient;
            });

            services.AddSingleton<IStorageService, StorageService>();
            return services;
        }

        public static IServiceCollection AddStorageServices(this IServiceCollection services)
        {
            var serviceProvider = services.BuildServiceProvider();
            var storageConfiguration = serviceProvider.GetRequiredService<IStorageServiceConfiguration>();

            services.AddSingleton(implementationFactory =>
            {
                return new BlobServiceClient(storageConfiguration.ConnectionString);
            });

            services.AddTransient<IStorageService, StorageService>();

            return services;
        }

        public static IServiceCollection AddStorageServices(this IServiceCollection services)
        {
            var serviceProvider = services.BuildServiceProvider();
            var storageConfiguration = serviceProvider.GetRequiredService<IStorageServiceConfiguration>();

            services.AddSingleton(implementationFactory =>
            {
                return new BlobServiceClient(storageConfiguration.ConnectionString);
            });

            services.AddTransient<IStorageService, StorageService>();

            return services;
        }

Microsoft.Extensions.Hosting.StorageServiceCollectionExtensions : Object

Methods :

public static IServiceCollection AddDashboardLogging(IServiceCollection services = )
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()