public static EventSourceConfiguration SetDefaultActivator(this EventSourceConfiguration config) { Precondition.For(() => config).NotNull(); var activator = new ActivatorDomainObjectActivator(); config.Activator = activator; config.StateActivator = activator; return(config); }
public static EventSourceConfiguration SetDomainObjectAssemblies(this EventSourceConfiguration config, params Assembly[] assembliesWithDomainObjects) { Precondition.For(() => config).NotNull(); Precondition.For(() => assembliesWithDomainObjects).NotNull().True(x => x.Any()); config.DomainObjectAssemblies = assembliesWithDomainObjects; return(config); }
public static IServiceCollection AddConventionBasedInMemoryCommandBus( this IServiceCollection services, EventSourceConfiguration config) { services.AddSingleton <EventSourceConfiguration>(config); services.AddSingleton <ICommandBus>(x => InMemoryCommandBus.CreateConventionCommandBus( x.GetRequiredService <IDomainObjectRepository>(), x.GetRequiredService <ILoggerFactory>(), x.GetRequiredService <EventSourceConfiguration>())); return(services); }
public static EventSourceConfiguration SetConventionBasedInMemoryCommandBus(this EventSourceConfiguration config) { Precondition.For(() => config).NotNull(); Precondition.For(() => config.DomainObjectRepository).NotNull(); Precondition.For(() => config.DomainObjectAssemblies).NotNull(); config.CommandBus = InMemoryCommandBus.CreateConventionCommandBus(config.DomainObjectRepository, config.DomainObjectAssemblies); return(config); }
public static EventSourceConfiguration AddEventSource(this IServiceCollection collection, EventSourceConfiguration config) { Precondition.For(() => config).NotNull(); Precondition.For(() => config.Activator).NotNull(); Precondition.For(() => config.CommandBus).NotNull(); Precondition.For(() => config.DomainObjectRepository).NotNull(); collection.AddSingleton(config.Activator); collection.AddSingleton(config.CommandBus); collection.AddSingleton(config.DomainObjectRepository); if (config.EventMapper != null) { collection.AddSingleton(config.EventMapper); } return(config); }
public static EventSourceConfiguration AddEventSource(this IServiceCollection collection, EventSourceConfiguration config) { Precondition.For(() => config).NotNull(); collection.AddSingleton(config); collection.TryAddSingleton <IEventTypeResolver, EventTypeResolver>(); collection.TryAddSingleton <IStateEventMapping, StateEventMapping>(); collection.TryAddSingleton <IEventSerializer, JsonEventSerializer>(); collection.TryAddSingleton <IEventHash>(x => { if (string.IsNullOrWhiteSpace(config.EventSecret)) { throw new InvalidOperationException( $"EventSecret must be set. Call \"{nameof(SetEventSecret)}\" before!"); } return(new ShaEventHash(config.EventSecret)); }); return(config); }
public static EventSourceConfiguration SetEventSecret(this EventSourceConfiguration config, string secret) { Precondition.For(secret, nameof(secret)).NotNullOrWhiteSpace(); config.EventSecret = secret; return(config); }