Beispiel #1
0
        public static IMessageOutboxConfigurator AddMongo(this IMessageOutboxConfigurator configurator)
        {
            var services = configurator.Services;
            var options  = configurator.Options;

            var inboxCollection = string.IsNullOrWhiteSpace(options.InboxCollection)
                ? "inbox"
                : options.InboxCollection;
            var outboxCollection = string.IsNullOrWhiteSpace(options.OutboxCollection)
                ? "outbox"
                : options.OutboxCollection;

            services.AddMongoRepository <InboxMessage, string>(inboxCollection);
            services.AddMongoRepository <OutboxMessage, string>(outboxCollection);
            services.AddInitializers(typeof(MongoOutboxInitializer));
            services.AddTransient <IMessageOutbox, MongoMessageOutbox>();
            services.AddTransient <IMessageOutboxAccessor, MongoMessageOutbox>();
            services.AddTransient <MongoOutboxInitializer>();

            BsonClassMap.RegisterClassMap <OutboxMessage>(m =>
            {
                m.AutoMap();
                m.UnmapMember(p => p.Message);
                m.UnmapMember(p => p.MessageContext);
            });

            return(configurator);
        }
Beispiel #2
0
        public static IMessageOutboxConfigurator AddInMemory(this IMessageOutboxConfigurator configurator,
                                                             string mongoSectionName = null)
        {
            configurator.Services.AddTransient <IMessageOutbox, InMemoryMessageOutbox>();

            return(configurator);
        }
Beispiel #3
0
    public static IMessageOutboxConfigurator AddEntityFramework <T>(this IMessageOutboxConfigurator configurator)
        where T : DbContext
    {
        var builder = configurator.Builder;

        builder.Services.AddTransient <IMessageOutbox, EntityFrameworkMessageOutbox <T> >();
        builder.Services.AddTransient <IMessageOutboxAccessor, EntityFrameworkMessageOutbox <T> >();

        return(configurator);
    }