public async Task <TAggregateRoot> GetByIdentityAsync(AggregateRootIdentity identity) { Contract.Assume(identity != null); var eventStream = await _eventStore.GetEventStreamAsync <TAggregateRoot>(identity); // build aggregate root from event stream var aggregateRoot = _eventStreamProcessor.Process(eventStream); // set external state tracker aggregateRoot.State.ExternalStateTracker = new EventProviderStateTracker(eventStream.EventProvider, eventStream.LatestVersion, _guidGenerator); return(aggregateRoot); }
static void Main(string[] args) { _eventStream = EventStreamBuilder.Configure(c => { c.WithPersistantStore(_store); c.ScanAssemblyWithType <Program>(); }) .BuildWithProcessor(TimeSpan.FromMinutes(5)); Console.WriteLine("Streaming events..."); _eventStream .Process(new SensorOnline("CPU")) .Process(new SensorDataReceived(45.3m)) .Process(new SensorDataReceived(42.6m)) .Process(new SensorDataReceived(40.1m)) .Process(new SensorDataReceived(40.1m)) .Process(new SensorDataReceived(40.1m)) .Process(new SensorDataReceived(39m)) .Process(new SensorOffline()) .Process(new SensorOnline("CPU")) .Process(new SensorDataReceived(40.5m)) .Process(new SensorOffline()); _eventStream.Shutdown(); Console.WriteLine("Done receiving events"); var eventsStored = _store.GetEvents(); Console.WriteLine($"{eventsStored.Count()} events written to persistance store"); }