コード例 #1
0
 public Decision(IEventStream stream)
 {
     foreach (var domainEvent in stream.GetEvents())
     {
         if (domainEvent is UserDeleted userDeleted)
         {
             Apply(userDeleted);
         }
     }
 }
コード例 #2
0
ファイル: Radio.cs プロジェクト: dublow/CqrsRadio
 private void Restore(IEventStream stream)
 {
     foreach (var domainEvent in stream.GetEvents())
     {
         if (domainEvent is RadioCreated radioCreated)
         {
             Name = radioCreated.Name;
             Url  = radioCreated.Url;
         }
     }
 }
コード例 #3
0
ファイル: Radio.cs プロジェクト: dublow/CqrsRadio
 public Decision(IEventStream stream)
 {
     _stream = stream;
     foreach (var domainEvent in _stream.GetEvents())
     {
         if (domainEvent is RadioDeleted radioDeleted)
         {
             Apply(radioDeleted);
         }
     }
 }
コード例 #4
0
        public async Task Start(CancellationToken cancellationToken)
        {
            var handlers = _allHandlersResolver();
            var types    = handlers.Select(h => h.GetType().GenericTypeArguments.Single());
            await _eventStream.Start(types);

            while (cancellationToken.IsCancellationRequested == false)
            {
                var eventWrappers = await _eventStream.GetEvents();

                foreach (var eventWrapper in eventWrappers)
                {
                    if (_processEventDelegateCache.ContainsKey(eventWrapper.Event.GetType()) == false)
                    {
                        _processEventDelegateCache.Add(eventWrapper.Event.GetType(), GetProcessEventDelegate(eventWrapper.Event.GetType()));
                    }

                    await _processEventDelegateCache[eventWrapper.Event.GetType()](eventWrapper);
                }
            }
        }
コード例 #5
0
 private void Restore(IEventStream stream)
 {
     foreach (var domainEvent in stream.GetEvents())
     {
         if (domainEvent is UserCreated userCreated)
         {
             Identity = userCreated.Identity;
         }
         else if (domainEvent is PlaylistAdded playlistAdded)
         {
             Playlist = new Playlist(playlistAdded.PlaylistId, playlistAdded.Name);
         }
         else if (domainEvent is SongAdded songAdded)
         {
             Playlist.AddSong(new Song(songAdded.SongId, songAdded.Title, songAdded.Artist));
         }
         else if (domainEvent is PlaylistDeleted)
         {
             Playlist = Playlist.Empty;
         }
     }
 }
コード例 #6
0
ファイル: Radio.cs プロジェクト: dublow/CqrsRadio
 public bool RadioSongExists(string name, RadioSong radioSong)
 {
     return(_stream.GetEvents().OfType <RadioSongParsed>()
            .Any(x => x == new RadioSongParsed(name, radioSong.Title, radioSong.Artist)));
 }