using Microsoft.Extensions.DependencyInjection; using MongoDB.Driver; using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.IdGenerators; using DataProviders.Collections; using DataProviders.Buckets; namespace DataProviders.Extensions { public static class ServiceCollectionExtensions { public static void RegisterDataproviders(this IServiceCollection services, IDataProvidersConfig appSettings) { var config = appSettings.Database; if (config == null) throw new NullReferenceException(); services.AddSingleton(x => new MongoClient(config.ConnectionString)); services.AddSingleton(); Mappings.RegisterClassMap(); services.AddSingleton(); #region Collections services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); #endregion #region Buckets services.AddSingleton(); #endregion } } }