public static async Task Run() { var appender = new MemoryAppendStoreAsync(); IEventStoreAsync es = new EventStoreAsync(appender); IDtoConverter <SayingDto, Saying> converter = new MyDtoConverters(); Stream mem = System.IO.File.Open("test.json", FileMode.OpenOrCreate, FileAccess.ReadWrite); IDtoSerializer <SayingDto> dtoSerializer = new FastJsonSerializer <SayingDto>(mem); ITableReaderWriter <Saying> said = new TableWriterForSerializer <Saying, SayingDto>(new MemoryHashTableWriter <Saying>(), converter, dtoSerializer); IAsyncProjection projection = new ConsoleProjection(new AsyncProjectFromImplementation(new SayingHistoryProjection(said))); IEventStoreAsync es2 = new EventStoreAsyncPublisher(es, projection); //IAsyncCommandDispatcher dispatcher = new ConsoleLoggerDispatcher(new CompositeAsyncCommandDispatcher(new SaySomething(es2))); ICommandHandler handler = new SaySomething(es2); await handler.GetExecutor(new SayCommand() { PersonId = new PersonId(1), Say = "Say hello", Timestamp = DateTime.UtcNow }).Execute(); foreach (var saying in said.GetAll().Result) { Console.Write("Entry in projection:\t\t"); Console.WriteLine("{0} said: {1}", saying.PersonId, saying.Said); } }
public static async Task Run() { var appender = new MemoryAppendStoreAsync(); IEventStoreAsync es = new EventStoreAsync(appender); IDtoConverter<SayingDto, Saying> converter = new MyDtoConverters(); Stream mem = System.IO.File.Open("test.json", FileMode.OpenOrCreate, FileAccess.ReadWrite); IDtoSerializer<SayingDto> dtoSerializer = new FastJsonSerializer<SayingDto>(mem); ITableReaderWriter<Saying> said = new TableWriterForSerializer<Saying, SayingDto>(new MemoryHashTableWriter<Saying>(), converter, dtoSerializer); IAsyncProjection projection = new ConsoleProjection(new AsyncProjectFromImplementation(new SayingHistoryProjection(said))); IEventStoreAsync es2 = new EventStoreAsyncPublisher(es, projection); //IAsyncCommandDispatcher dispatcher = new ConsoleLoggerDispatcher(new CompositeAsyncCommandDispatcher(new SaySomething(es2))); ICommandHandler handler = new SaySomething(es2); await handler.GetExecutor(new SayCommand() { PersonId = new PersonId(1), Say = "Say hello", Timestamp = DateTime.UtcNow }).Execute(); foreach (var saying in said.GetAll().Result) { Console.Write("Entry in projection:\t\t"); Console.WriteLine("{0} said: {1}", saying.PersonId, saying.Said); } }