Пример #1
0
        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);
        }
Пример #2
0
        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");
            }
        }
Пример #3
0
 public EventQueueParam(EventQueueType _type, object _option)
 {
     Type = _type;
     Option = _option;
 }