public async Task WriteASingleEventAsynchronously() { var eventStreamId = new Guid("A0E50259-7345-48F9-84B4-BEEB5CEC662C"); using (var storage = new AtomEventsInMemory()) { var pageSize = 25; var serializer = DataContractContentSerializer.Scan( typeof(UserCreated).Assembly); var obs = new AtomEventObserver <IUserEvent>( eventStreamId, // a Guid pageSize, // an Int32 storage, // an IAtomEventStorage object serializer); // an IContentSerializer object var userCreated = new UserCreated { UserId = eventStreamId, UserName = "******", Password = "******", Email = "*****@*****.**" }; await obs.AppendAsync(userCreated); Assert.NotEmpty(storage); } }
public async Task WriteASingleEventAsynchronously() { var eventStreamId = new Guid("A0E50259-7345-48F9-84B4-BEEB5CEC662C"); using (var storage = new AtomEventsInMemory()) { var pageSize = 25; var serializer = DataContractContentSerializer.Scan( typeof(UserCreated).Assembly); var obs = new AtomEventObserver<IUserEvent>( eventStreamId, // a Guid pageSize, // an Int32 storage, // an IAtomEventStorage object serializer); // an IContentSerializer object var userCreated = new UserCreated { UserId = eventStreamId, UserName = "******", Password = "******", Email = "*****@*****.**" }; await obs.AppendAsync(userCreated); Assert.NotEmpty(storage); } }
public IUserVisitor Visit(UserCreated @event) { var user = new User( @event.UserId, @event.UserName, @event.Password, @event.Email, false); return new UserVisitor(this.users.Concat(new[] { user })); }
public void WriteASingleEventSynchronously() { var eventStreamId = new Guid("A0E50259-7345-48F9-84B4-BEEB5CEC662C"); /* Uses file storage to provide a documentation example of how to * do that. */ var directory = new DirectoryInfo( Path.Combine( Environment.CurrentDirectory, Guid.NewGuid().ToString("N"))); try { var storage = new AtomEventsInFiles(directory); var pageSize = 25; var serializer = new DataContractContentSerializer( new TypeResolutionTable( new TypeResolutionEntry( "urn:grean:samples:user-sign-up", "user-created", typeof(UserCreated)), new TypeResolutionEntry( "urn:grean:samples:user-sign-up", "email-verified", typeof(EmailVerified)), new TypeResolutionEntry( "urn:grean:samples:user-sign-up", "email-changed", typeof(EmailChanged)))); IObserver <IUserEvent> obs = new AtomEventObserver <IUserEvent>( eventStreamId, // a Guid pageSize, // an Int32 storage, // an IAtomEventStorage object serializer); // an IContentSerializer object var userCreated = new UserCreated { UserId = eventStreamId, UserName = "******", Password = "******", Email = "*****@*****.**" }; obs.OnNext(userCreated); Assert.NotEmpty(storage); } finally { directory.Delete(recursive: true); } }
public IUserVisitor Visit(UserCreated @event) { var user = new User( @event.UserId, @event.UserName, @event.Password, @event.Email, false); return(new UserVisitor(this.users.Concat(new[] { user }))); }
public void WriteASingleEventSynchronously() { var eventStreamId = new Guid("A0E50259-7345-48F9-84B4-BEEB5CEC662C"); /* Uses file storage to provide a documentation example of how to * do that. */ var directory = new DirectoryInfo( Path.Combine( Environment.CurrentDirectory, Guid.NewGuid().ToString("N"))); try { var storage = new AtomEventsInFiles(directory); var pageSize = 25; /* This is an example of using * DataContractContentSerializer.CreateTypeResolver, so it * should not be refactored to one of the terser * alternatives. */ var resolver = DataContractContentSerializer.CreateTypeResolver( typeof(UserCreated).Assembly); var serializer = new DataContractContentSerializer(resolver); IObserver <IUserEvent> obs = new AtomEventObserver <IUserEvent>( eventStreamId, // a Guid pageSize, // an Int32 storage, // an IAtomEventStorage object serializer); // an IContentSerializer object var userCreated = new UserCreated { UserId = eventStreamId, UserName = "******", Password = "******", Email = "*****@*****.**" }; obs.OnNext(userCreated); Assert.NotEmpty(storage); } finally { directory.Delete(recursive: true); } }
public void WriteASingleEventSynchronously() { var eventStreamId = new Guid("A0E50259-7345-48F9-84B4-BEEB5CEC662C"); /* Uses file storage to provide a documentation example of how to * do that. */ var directory = new DirectoryInfo( Path.Combine( Environment.CurrentDirectory, Guid.NewGuid().ToString("N"))); try { var storage = new AtomEventsInFiles(directory); var pageSize = 25; /* This is an example of using * DataContractContentSerializer.CreateTypeResolver, so it * should not be refactored to one of the terser * alternatives. */ var resolver = DataContractContentSerializer.CreateTypeResolver( typeof(UserCreated).Assembly); var serializer = new DataContractContentSerializer(resolver); IObserver<IUserEvent> obs = new AtomEventObserver<IUserEvent>( eventStreamId, // a Guid pageSize, // an Int32 storage, // an IAtomEventStorage object serializer); // an IContentSerializer object var userCreated = new UserCreated { UserId = eventStreamId, UserName = "******", Password = "******", Email = "*****@*****.**" }; obs.OnNext(userCreated); Assert.NotEmpty(storage); } finally { directory.Delete(recursive: true); } }
public async Task WriteASingleEventAsynchronously() { var eventStreamId = new Guid("A0E50259-7345-48F9-84B4-BEEB5CEC662C"); using (var storage = new AtomEventsInMemory()) { var pageSize = 25; var serializer = new DataContractContentSerializer( new TypeResolutionTable( new TypeResolutionEntry( "urn:grean:samples:user-sign-up", "user-created", typeof(UserCreated)), new TypeResolutionEntry( "urn:grean:samples:user-sign-up", "email-verified", typeof(EmailVerified)), new TypeResolutionEntry( "urn:grean:samples:user-sign-up", "email-changed", typeof(EmailChanged)))); var obs = new AtomEventObserver <IUserEvent>( eventStreamId, // a Guid pageSize, // an Int32 storage, // an IAtomEventStorage object serializer); // an IContentSerializer object var userCreated = new UserCreated { UserId = eventStreamId, UserName = "******", Password = "******", Email = "*****@*****.**" }; await obs.AppendAsync(userCreated); Assert.NotEmpty(storage); } }