private object DeserializeUserStreamEvent(string content)
        {
            var @event = DeserializeSingle(content, typeof(TwitterUserStreamEventBase)) as TwitterUserStreamEventBase;

            var target = JObject.Parse(content);

            var result = new TwitterUserStreamEvent(@event);

            var targetObject = target["target_object"];

            var json = targetObject.ToString();

            if (targetObject["recipient_screen_name"] != null)
            {
                result.TargetObject = DeserializeSingle(json, typeof(TwitterDirectMessage)) as TwitterDirectMessage;
            }
            else if (targetObject["slug"] != null)
            {
                result.TargetObject = DeserializeSingle(json, typeof(TwitterList)) as TwitterList;
            }
            else
            {
                result.TargetObject = DeserializeSingle(json, typeof(TwitterStatus)) as TwitterStatus;
            }

            return(result);
        }
Esempio n. 2
0
 void EventAction(TwitterUserStreamEvent p)
 {
     Console.WriteLine(p.ToString());
     switch (p.Event)
     {
         case "favorite":
             var fs = p.TargetObject as TwitterStatus;
             if (p.Source == CurrentUser) break;
             if (p.Target != CurrentUser) break;
             MainMention.Dispatcher.BeginInvoke(new Action(() =>
             {
                 MainMention.Items.Insert(0, CreateFavoritePanel(fs, p.Source));
             }));
             NotifyFavorited(p);
             foreach (var pl in FavoritePlugins) pl.OnFavorite(Service, p.Source, fs);
             break;
         case "unfavorite":
             var fs2 = p.TargetObject as TwitterStatus;
             if (p.Source == CurrentUser) break;
             if (p.Target != CurrentUser) break;
             MainMention.Dispatcher.BeginInvoke(new Action(() =>
             {
                 MainMention.Items.Insert(0, CreateUnfavoritePanel(fs2, p.Source));
             }));
             NotifyUnfavorited(p);
             foreach (var pl in UnfavoritePlugins) pl.OnUnfavorite(Service, p.Source, fs2);
             break;
         case "user_update":
             Console.WriteLine("やったぜ。");
             break;
         default:
             Console.WriteLine(p.RawSource.ToString());
             break;
     }
     if (MainMention.Items.Count > MentionMax)
     {
         MainMention.Dispatcher.BeginInvoke(new Action(() =>
         {
             MainMention.Items.RemoveAt(MentionMax);
         }));
     }
 }
Esempio n. 3
0
 public void NotifyUnfavorited(TwitterUserStreamEvent p)
 {
     var st = p.TargetObject as TwitterStatus;
     ShowBalloon(
         String.Format(MessageMentionUnfavoritedFormat, p.Source.Name),
         st.TextDecoded,
         ToolTipIcon.Info
         );
     if (NotifySoundUnfavoritedPlayer != null) NotifySoundUnfavoritedPlayer.Play();
 }