예제 #1
0
        private void TryRaiseTweetFavouritedEvents(string eventName, JObject jsonObjectEvent)
        {
            var json = jsonObjectEvent.ToString();
            var favouriteTweetEvent      = jsonObjectEvent[eventName];
            var favouritedTweetEventJson = favouriteTweetEvent.ToString();
            var favouriteEventDTOs       = _jsonObjectConverter.Deserialize <AccountActivityFavouriteEventDTO[]>(favouritedTweetEventJson);

            favouriteEventDTOs.ForEach(favouriteEventDTO =>
            {
                var tweet = _factories.CreateTweet(favouriteEventDTO.FavouritedTweet);
                var user  = _factories.CreateUser(favouriteEventDTO.User);

                var accountActivityEvent = new AccountActivityEvent <Tuple <ITweet, IUser> >(new Tuple <ITweet, IUser>(tweet, user))
                {
                    AccountUserId = AccountUserId,
                    EventDate     = tweet.CreatedAt,
                    Json          = json
                };

                var eventArgs = new TweetFavouritedEvent(accountActivityEvent);

                this.Raise(TweetFavourited, eventArgs);

                if (eventArgs.InResultOf == TweetFavouritedRaisedInResultOf.Unknown)
                {
                    this.Raise(EventKnownButNotFullySupportedReceived, new EventKnownButNotSupported(json, eventArgs));
                }
            });
        }
 private void TweetFavourited(object sender, TweetFavouritedEvent e)
 {
     Console.WriteLine($">>> Tweet has been favourited by {e.FavouritedBy}:\n{e.Tweet}");
 }