public static EventDenormalizer AttachDenormalizer(this IEventStoreConnection connection, IStreamPositionGateway gtw, UserCredentials creds, string streamName, Func <Type, object> normalizerFactory, params Assembly[] normalizerAssemblies) { var subscriber = new EventSubscriber(connection, creds, streamName, new EventTransformator(new JsonEventSerializer(new EventTypeResolver()))); var eventHandler = new ConventionEventHandler(normalizerFactory, normalizerAssemblies); var result = new EventDenormalizer(subscriber, eventHandler, gtw); return(result); }
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(); }
public static EventDenormalizer UseConvetionBasedDenormalizer(this IApplicationBuilder app, ILoggerFactory logger) // TODO Extract Object Factory like the DomainObjectFacotry { Precondition.For(() => app).NotNull(); var config = app.ApplicationServices.GetRequiredService <DenormalizerConfiguration>(); var result = new EventDenormalizer(config.Subscriber, new ConventionEventHandler(config.Activator, logger, config.DenormalizerAssemblies), config.StreamPositionGateway); return(result); }
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); }