public static void UseMongoDb <TContext>(this EntityContextOptionsBuilder <TContext> builder, string connectionString, string database, EventQueueType eventQueueType = EventQueueType.InMemory) where TContext : EntityContext { RegisterConventions(MongoDB.Bson.GuidRepresentation.Standard); var options = new MongoEntityContextOptions <TContext> { ConnectionString = connectionString, DatabaseName = database, }; builder.Builder .Services .AddSingleton(options) .AddTransient <IDatabaseTransactionManager <TContext>, MongoDatabaseTransactionManager <TContext> >() .AddScoped <IDatabaseCollectionProvider <TContext>, MongoDatabaseCollectionProvider <TContext> >() .AddScoped <MongoDatabaseFactory <TContext> >() .AddSingleton <MongoClientFactory <TContext> >() .AddEventQueue <TContext>(eventQueueType); }
private static IServiceCollection AddEventQueue <TContext>(this IServiceCollection services, EventQueueType eventQueueType) where TContext : EntityContext { switch (eventQueueType) { case EventQueueType.InMemory: return(services.AddInMemoryEventQueue <TContext>()); case EventQueueType.Mongo: return(services.AddMongoEventQueue <TContext>()); default: throw new NotImplementedException($"Event queue {eventQueueType} not implemented"); } }
public EventQueueParam(EventQueueType _type, object _option) { Type = _type; Option = _option; }