Пример #1
0
        public Media(JToken media)
        {
            Images = new ThreadSafeObservableCollection <Uri>();
            if (media.Type != JTokenType.Undefined)
            {
                JToken mediaRoot;
                switch ((int)media[0][0])
                {
                case 35:
                    mediaRoot = (JArray)media[2]["29646191"];
                    Icon      = new Uri(prefix.FormatWith(mediaRoot[6]), UriKind.Absolute);
                    if (mediaRoot[5].Type == JTokenType.Array)
                    {
                        Images.Add(new Uri(prefix.FormatWith(((string)mediaRoot[5][0]).Replace("resize_h=150&resize_w=150", "resize_h=400&resize_w=400")), UriKind.Absolute));
                    }
                    LineOne      = (string)mediaRoot[2];
                    LineTwo      = (string)mediaRoot[3];
                    LinkLocation = new Uri((string)mediaRoot[0], UriKind.Absolute);
                    break;

                case 249:
                    mediaRoot = (JArray)media[1]["27639957"];
                    Images.Add(new Uri(prefix.FormatWith(mediaRoot[0][5][0]), UriKind.Absolute));
                    break;

                case 250:
                    if (media[1].Type == JTokenType.Object)
                    {
                        mediaRoot = (JArray)media[1]["27847199"];
                    }
                    else
                    {
                        mediaRoot    = (JArray)media[2]["27847199"];
                        LineOne      = (string)mediaRoot[1];
                        LinkLocation = new Uri("//Pages/Album.xaml?uid={0}&aid={1}".FormatWith(mediaRoot[4], mediaRoot[5]), UriKind.Relative);
                    }
                    foreach (JToken item in mediaRoot[3])
                    {
                        Images.Add(new Uri(prefix.FormatWith(item[0][5][0]), UriKind.Absolute));
                    }
                    break;
                }
            }
        }
        public Profile(JToken profile)
        {
            FullName   = (string)profile[2][4][3];
            Tagline    = (string)profile[2][33][1];
            Occupation = (string)profile[2][6][1];
            Education  = new ThreadSafeObservableCollection <Education>();
            foreach (JToken education in profile[2][8][1])
            {
                Education.Add(new Education(education));
            }
            Introduction   = (string)profile[2][14][1];
            PlacesLivedMap = "https:" + (string)profile[2][10];
            Birthday       = (string)profile[2][16][1];
            if (profile[2][17][1].Type != JTokenType.Undefined)
            {
                switch ((int)profile[2][17][1])
                {
                case 1:
                    Gender = "Male";
                    break;

                case 2:
                    Gender = "Female";
                    break;

                case 3:
                    Gender = "Other";
                    break;
                }
            }

            OtherProfiles = new ThreadSafeObservableCollection <OtherProfile>();
            foreach (JToken otherProfile in profile[2][51][0])
            {
                OtherProfiles.Add(new OtherProfile(otherProfile));
            }

            Posts = new ThreadSafeObservableCollection <Post>();
            foreach (JToken post in profile[4][0])
            {
                Posts.Add(new Post(post, 200, 10));
            }
        }
Пример #3
0
        public Notification(JToken notification, bool unread)
        {
            Unread  = unread;
            Type    = (NotificationType)(int)notification[1];
            ID      = (string)notification[10];
            LineOne = new Paragraph();
            LineTwo = new Paragraph();
            Images  = new ThreadSafeObservableCollection <string>();
            switch (Type)
            {
            case NotificationType.Post:
                if (notification[18][0][0].Type != JTokenType.Undefined)
                {
                    if (notification[18][0][7][1].Type != JTokenType.Undefined)
                    {
                        Post post = new Post(notification[18][0][0], 100, 1, false);
                        Image = post.AuthorPhoto;
                        LineOne.Inlines.Add(new Run()
                        {
                            Text = post.Author + ": "
                        });
                        foreach (Inline inline in Utils.ProcessRawContent((string)notification[18][0][7][1]).Inlines)
                        {
                            if (inline is Run)
                            {
                                LineOne.Inlines.Add(RichTextHelper.Clone((Run)inline));
                            }
                        }
                    }
                    if (notification[18][0][7][2].Type != JTokenType.Undefined)
                    {
                        string lineTwoId = (string)notification[18][0][7][3];
                        foreach (JToken block in notification[2])
                        {
                            foreach (JToken item in block[1])
                            {
                                if ((string)item[2][3] == lineTwoId)
                                {
                                    Image = new Uri("https:" + ((string)item[2][2]).Replace("photo.", "s64-c-k/photo."), UriKind.Absolute);
                                    LineTwo.Inlines.Add(new Run()
                                    {
                                        Text = (string)item[2][0], FontWeight = FontWeights.Bold
                                    });
                                    LineTwo.Inlines.Add(new Run()
                                    {
                                        Text = " - "
                                    });
                                    foreach (Inline inline in Utils.ProcessRawContent((string)notification[18][0][7][2]).Inlines)
                                    {
                                        if (inline is Run)
                                        {
                                            LineTwo.Inlines.Add(RichTextHelper.Clone((Run)inline));
                                        }
                                    }
                                    return;
                                }
                            }
                        }
                    }

                    /*
                     * foreach (JToken block in notification[2])
                     * {
                     *  switch ((int)block[0])
                     *  {
                     *      case 4:
                     *          foreach (JToken item in block[1])
                     *          {
                     *              switch ((int)item[1])
                     *              {
                     *                  case 20:
                     *                      LineTwo.Inlines.Add(new Run() { Text = "+1  ", FontStyle = FontStyles.Italic, FontWeight = FontWeights.Bold });
                     *                      LineTwo.Inlines.Add(new Run() { Text = "your post by " + (string)item[2][0] + ". " });
                     *                      Image = "https:" + ((string)item[2][2]).Replace("photo.", "s64-c-k/photo.");
                     *                      break;
                     *                  case 21:
                     *                      LineTwo.Inlines.Add(new Run() { Text = "+1  ", FontStyle = FontStyles.Italic, FontWeight = FontWeights.Bold });
                     *                      LineTwo.Inlines.Add(new Run() { Text = "your comment by " + (string)item[2][0] + ". " });
                     *                      Image = "https:" + ((string)item[2][2]).Replace("photo.", "s64-c-k/photo.");
                     *                      break;
                     *              }
                     *          }
                     *          break;
                     *      case 6:
                     *          LineTwo.Inlines.Add(new Run() { Text = "1 new reshare ", FontStyle = FontStyles.Italic, FontWeight = FontWeights.Bold });
                     *          LineTwo.Inlines.Add(new Run() { Text = "by " + (string)block[1][0][2][0] + "." });
                     *          break;
                     *      case 11:
                     *          foreach (JToken item in block[1])
                     *          {
                     *              switch ((int)item[1])
                     *              {
                     *                  case 3:
                     *                      break;
                     *              }
                     *          }
                     *          break;
                     *  }
                     * }
                     */
                }
                else
                {
                    LineOne.Inlines.Add(new Run()
                    {
                        Text = "{0} interacted on a post with you.".FormatWith(notification[2][0][1][0][2][0])
                    });
                    LineTwo.Inlines.Add(new Run()
                    {
                        Text = "The post no longer exists."
                    });
                }
                break;

            case NotificationType.Circle:
                foreach (JToken block in notification[2])
                {
                    if ((int)block[0] != 7 && (int)block[0] != 21)
                    {
                        continue;
                    }
                    else
                    {
                        int count = ((JArray)block[1]).Count;
                        if ((int)block[0] == 7)
                        {
                            LineOne.Inlines.Add(new Run()
                            {
                                Text = "Added you on Google+ ({0}): ".FormatWith(count)
                            });
                        }
                        else
                        {
                            LineOne.Inlines.Add(new Run()
                            {
                                Text = "Added you back on Google+ ({0}): ".FormatWith(count)
                            });
                        }
                        Images.Clear();
                        if (count == 1)
                        {
                            LineOne.Inlines.Add(new Run()
                            {
                                Text = "{0}.".FormatWith(block[1][0][2][0])
                            });
                            Images.Add("https:{0}".FormatWith(((string)block[1][0][2][2]).Replace("photo.", "s64-c-k/photo.")));
                        }
                        else
                        {
                            for (int i = 0; i < count - 2; i++)
                            {
                                LineOne.Inlines.Add(new Run()
                                {
                                    Text = "{0}, ".FormatWith(block[1][i][2][0])
                                });
                                Images.Add("https:{0}".FormatWith(((string)block[1][i][2][2]).Replace("photo.", "s64-c-k/photo.")));
                            }
                            LineOne.Inlines.Add(new Run()
                            {
                                Text = "{0} and {1}.".FormatWith(block[1][count - 2][2][0], block[1][count - 1][2][0])
                            });
                            Images.Add("https:{0}".FormatWith(((string)block[1][count - 2][2][2]).Replace("photo.", "s64-c-k/photo.")));
                            Images.Add("https:{0}".FormatWith(((string)block[1][count - 1][2][2]).Replace("photo.", "s64-c-k/photo.")));
                        }
                    }
                }
                break;
            }
        }
Пример #4
0
 public Post()
 {
     Replies = new ThreadSafeObservableCollection <Comment>();
 }