using Canon.Server.Services; using MongoDB.Driver; namespace Canon.Server.Extensions; public static class ServiceProviderExtensions { public static void AddGridFs(this IServiceCollection serviceCollection, string connectionString, string databaseName) { serviceCollection.AddSingleton( _ => new MongoClient(connectionString)); serviceCollection.AddScoped(provider => { IMongoClient client = provider.GetRequiredService(); return new GridFsService(client, databaseName); }); } }