using Elsa.Features.Abstractions; using Elsa.Features.Services; using Microsoft.Extensions.DependencyInjection; using MongoDB.Driver; namespace Elsa.MongoDb.Common; /// /// Base class for features that configure MongoDb persistence. /// public abstract class PersistenceFeatureBase : FeatureBase { /// protected PersistenceFeatureBase(IModule module) : base(module) { } /// /// Registers a . /// /// The type of the store. /// The document type of the store. protected void AddStore() where TDocument : class where TStore : class { Services .AddSingleton>() .AddSingleton() ; } /// /// Registers a . /// /// The name of the collection. /// The document type of the collection. protected void AddCollection(string collectionName) where TDocument : class { Services.AddSingleton( sp => sp.GetRequiredService() .GetCollection(collectionName)); } }