public static void CustomersRenameHistory() { var state = new CustomerRenameHistory(); state = state.Apply(new CustomerCreated("Great-Customer-Id", "Great Customer", DateTime.UtcNow)); state = state.Apply(new CustomerRenamed("Great-Customer-Id", "Great Customer GmbH", DateTime.UtcNow)); state = state.Apply(new CustomerRenamed("Great-Customer-Id", "Great Customer AG", DateTime.UtcNow)); Console.WriteLine("Customers rename history:\n" + state.RenameHistory); Console.WriteLine(); }
public static async Task CustomersRenameHistoryOfGreatCustomerEventStreamAsync() { var greatCustomer = await GetOrCreateGreatCustomerAsync().ConfigureAwait(false); var events = await engine.LoadStreamEntriesByStreamAsync(greatCustomer.Id) .Select(x => serializer.Deserialize(x.Payload)) .ToListAsync(); var state = CustomerRenameHistory.LoadState((CustomerRenameHistory)null, events); Console.WriteLine("Customers rename history of Great Customer event stream:\n" + state.RenameHistory); Console.WriteLine(); }
public static async Task CustomersRenameHistoryOfGreatCustomerEventStreamWithEventTypeConstraintsAsync() { var greatCustomer = await GetOrCreateGreatCustomerAsync().ConfigureAwait(false); var events = await engine.LoadStreamEntriesByStreamAsync( greatCustomer.Id, 0, int.MaxValue, new[] { typeof(CustomerCreated), typeof(CustomerRenamed) }) .Select(x => serializer.Deserialize(x.Payload)) .ToListAsync(); var state = CustomerRenameHistory.LoadState((CustomerRenameHistory)null, events); Console.WriteLine("Customers rename history of Great Customer event stream (with payload type constraints):\n" + state.RenameHistory); Console.WriteLine(); }