public override void SetUp() { base.SetUp(); DatabaseHelper.CleanEvents(); DatabaseHelper.CleanEventStreams(); var eventRepository = new EventRepository(DatabaseHelper.GetConnectionStringBuilder()); EventSerializer = new Serialization.Newtonsoft.EventSerializer(); var logger = new SerilogLogger(Log.ForContext<EventStore>()); var eventStore = new EventStore( EventSerializer, eventRepository, logger, Guid.NewGuid); AggregateContext = new AggregateContext( eventStore, null, // TODO: replace with actual SnapshotStore new AggregateHydrator(), new DummyDispatcher()); }
public static Product Create( IAggregateContext context, ProductName productName) { return(Product.CreateWithEvent <Product, ProductCreated>( context, new ProductCreated( ProductIdentifier.New(), productName))); }
public static Order Create( IAggregateContext context, OrderIdentifier orderIdentifier, CustomerIdentifier customerIdentifier) { return(CreateWithEvent <Order, OrderCreated>( context, new OrderCreated( orderIdentifier, customerIdentifier))); }
protected static TAggregateRoot CreateWithEvent <TAggregateRoot, TEvent>(IAggregateContext context, TEvent firstEvent) where TAggregateRoot : AggregateRoot <TIdentifier> where TEvent : Event { var now = context.GetDateTime(); var aggregateRoot = CallAggregateConstructor <TAggregateRoot, TEvent>(new TypedEvent <TEvent>(now, firstEvent)); aggregateRoot._context = context; aggregateRoot.ApplyInitialEvent(new LoadedEvent(now, firstEvent)); return(aggregateRoot); }
void IAggregateLoader.SetAggregateContext(IAggregateContext context) { _context = context; }
public ProductRepository(IEventStore eventStore, IAggregateContext context) : base(eventStore, context) { }
protected override AggregateValue CreateAggregate(IAggregateContext context) { return this.CreateAggregate(context.DataType); }
public Repository(IEventStore eventStore, IAggregateContext aggregateContext) { AggregateContext = aggregateContext; _eventStore = eventStore; }
public OrderRepository(IEventStore eventStore, IAggregateContext context) : base(eventStore, context) { }