Ejemplo n.º 1
0
        private static void StartDenormalizer(IMongoDatabase db, params Assembly[] normalizerASsemblies)
        {
            var subs = new MongoEventSubscriber(db);
            var pos  = new MongoStreamPositionGateway(db, null);
            var normalizerFactory = new Func <Type, object>(Activator.CreateInstance);

            var eventHandler = new ConventionEventHandler(normalizerFactory, normalizerASsemblies);
            var result       = new EventDenormalizer(subs, eventHandler, pos);

            result.StartAsync(TimeSpan.FromSeconds(1)).Wait();
        }
Ejemplo n.º 2
0
        public static async Task <IApplicationBuilder> UseCustomerDenormalizerAsync(this IApplicationBuilder app)
        {
            var cfg = app.ApplicationServices.GetRequiredService <DenormalizerConfiguration>();

            app.UseServiceProviderActivator();
            var foo = cfg.Activator as ServiceCollectionActivator;

            foo.UseProvider(app.ApplicationServices);

            EventDenormalizer denormalizer = app.UseConvetionBasedDenormalizer();

            await denormalizer.StartAsync(TimeSpan.FromMilliseconds(250));

            return(app);
        }