示例#1
0
        public static List<UserEntity> ParseUserList(String json, UserAccountEntity userAccountEntity)
        {
            var userEntities = new List<UserEntity>();
            JArray a = JArray.Parse(json);
            foreach (var jToken in a)
            {
                var o = (JObject) jToken;
                var user = new UserEntity
                {
                    CoverImage = (String)o["cover_image_url_https"] ?? string.Empty,
                    CreatedAt = (String) o["created_at"] == null ? 0 : FixTime((String) o["created_at"]),
                    Description = (String) o["description"] ?? string.Empty,
                    FavoritesCount =
                        (String) o["favorites_count"] == null ? 0 : long.Parse((String) o["favorites_count"]),
                    FollowersCount =
                        (String) o["followers_count"] == null ? 0 : long.Parse((String) o["followers_count"]),
                    FriendsCount = (String) o["friends_count"] == null ? 0 : long.Parse((String) o["friends_count"]),
                    IsFollowing =
                        (String) o["following"] != null &&
                        (!((String) o["following"]).Equals("underdevelopment") && Boolean.Parse((String) o["following"])),
                    IsFollowRequest =
                        (String) o["follow_request_sent"] != null &&
                        (!((String) o["follow_request_sent"]).Equals("underdevelopment") &&
                         Boolean.Parse((String) o["follow_request_sent"])),
                    IsProtected = (String) o["protected"] != null && Boolean.Parse((String) o["protected"]),
                    Location = (String) o["location"] ?? string.Empty,
                    Name = Regex.Replace((String) o["name"], @"\t|\n|\r", ""),
                    ProfileImage = (String) o["profile_image_url_https"],
                    ScreenName = (String) o["screen_name"],
                    StatusCount = (String) o["statuses_count"] == null ? 0 : long.Parse((String) o["statuses_count"]),
                    URL = (String) o["url"] ?? string.Empty,
                    UserID = long.Parse((String) o["id"])
                };
                user.IsNotFollowing = !user.IsFollowing;
                if (userAccountEntity != null && userAccountEntity.GetUserEntity() != null)
                {
                    user.IsCurrentUser = user.UserID == userAccountEntity.GetUserEntity().UserID;
                    user.IsNotCurrentUser = !user.IsCurrentUser;
                }

                userEntities.Add(user);
            }
            return userEntities;
        }
 public async Task<bool> BindPictureGallery(UserAccountEntity userAccountEntity)
 {
     PictureCollection = new InfiniteScrollingHtmlParseImageCollection
     {
         timeline = "Pictures",
         userAccountEntity = userAccountEntity,
         Offset = 0,
         userName = userAccountEntity.GetUserEntity().ScreenName,
         MediaCollection = new ObservableCollection<MediaEntity>()
     };
     List<MediaEntity> items =
         await AlbumManager.GetAlbumList(0, userAccountEntity.GetUserEntity().ScreenName, userAccountEntity);
     foreach (MediaEntity item in items)
     {
         PictureCollection.MediaCollection.Add(item);
     }
     PictureCollection.Offset = 20;
     albumGallery.DataContext = PictureCollection;
     albumGallery.ItemRealized += albumGallery_ItemRealized;
     return true;
 }
示例#3
0
        public static List<PostEntity> Parse(String json, UserAccountEntity userAccountEntity)
        {
            var entity = new List<PostEntity>();
            JArray a = JArray.Parse(json);
            foreach (var jToken in a)
            {
                var o = (JObject) jToken;
                var post = new PostEntity
                {
                    CreatedAt = FixTime((String) o["created_at"]),
                    FavoritedCount = long.Parse((String) o["favorited_count"]),
                    InReplyToScreenName = (String) o["in_reply_to_screen_name"],
                    InReplyToStatusID =
                        long.Parse(String.IsNullOrEmpty((String) o["in_reply_to_status_id"])
                            ? "0"
                            : (String) o["in_reply_to_status_id"]),
                    InReplyToUserID =
                        long.Parse(String.IsNullOrEmpty((String) o["in_reply_to_user_id"])
                            ? "0"
                            : (String) o["in_reply_to_user_id"]),
                    IsFavorited = Boolean.Parse((String) o["favorited"]),
                    IsSpreaded = Boolean.Parse((String) o["spread"]),
                    CanBeFavorited = !Boolean.Parse((String) o["favorited"]),
                    CanBeSpread = !Boolean.Parse((String) o["spread"]),
                    ReplyStatus =
                        (JObject) o["reply_status"] == null
                            ? null
                            : ParsePost((JObject) o["reply_status"], userAccountEntity),
                    SourceName = (String) o["source"]["name"],
                    SourceUrl = (String) o["source"]["url"],
                    SpreadCount = long.Parse((String) o["spread_count"]),
                    SpreadStatus =
                        (JObject) o["spread_status"] == null
                            ? null
                            : ParsePost((JObject) o["spread_status"], userAccountEntity),
                    StatusID = long.Parse((String) o["id"]),
                    Post = (String) o["text"],
                    User = UserEntity.Parse(o["user"].ToString(), userAccountEntity),
                    ImageUrl =
                        (JObject) o["entities"]["media"] == null
                            ? null
                            : ParseEntities((JObject) o["entities"], "media_url_https"),
                    ImageLargeUrl =
                        (JObject) o["entities"]["media"] == null
                            ? null
                            : ParseEntities((JObject) o["entities"], "media_url_https") + "?large",
                    Media =
                        (JObject) o["entities"]["media"] == null ? null : ParseEntities((JObject) o["entities"], "type")
                };
                post.Links =
                    post.Post.Split("\t\n ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
                        .Where(s => s.StartsWith("http://") || s.StartsWith("www."));
                post.IsCreator = post.User.UserID == userAccountEntity.GetUserEntity().UserID;
                post.CreatedDate = ToDate(post.CreatedAt);
                post.IsNotCreator = !post.IsCreator;
                if (post.Media != null)
                {
                    if (post.Media.Equals("photo"))
                    {
                        post.HasMediaString = "画像 ";
                        post.HasMedia = true;
                    }
                }
                if (post.SpreadStatus != null)
                {
                    post.SpreadStatus.SpreadBy = string.Format("{0}さんがイイネ!しました。", post.User.Name);
                    entity.Add(post.SpreadStatus);
                }
                else
                {
                    entity.Add(post);
                }
            }

            return entity;
        }
示例#4
0
 public static PostEntity ParsePost(JObject o, UserAccountEntity userAccountEntity)
 {
     var post = new PostEntity
     {
         CreatedAt = FixTime((String) o["created_at"]),
         FavoritedCount = long.Parse((String) o["favorited_count"]),
         InReplyToScreenName = (String) o["in_reply_to_screen_name"],
         InReplyToStatusID =
             long.Parse(String.IsNullOrEmpty((String) o["in_reply_to_status_id"])
                 ? "0"
                 : (String) o["in_reply_to_status_id"]),
         InReplyToUserID =
             long.Parse(String.IsNullOrEmpty((String) o["in_reply_to_user_id"])
                 ? "0"
                 : (String) o["in_reply_to_user_id"]),
         IsFavorited = Boolean.Parse((String) o["favorited"]),
         IsSpreaded = Boolean.Parse((String) o["spread"]),
         ReplyStatus =
             (JObject) o["reply_status"] == null
                 ? null
                 : ParsePost((JObject) o["reply_status"], userAccountEntity),
         SourceName = (String) o["source"]["name"],
         SourceUrl = (String) o["source"]["url"],
         SpreadCount = long.Parse((String) o["spread_count"]),
         SpreadStatus =
             (JObject) o["spread_status"] == null
                 ? null
                 : ParsePost((JObject) o["spread_status"], userAccountEntity),
         StatusID = long.Parse((String) o["id"]),
         Post = (String) o["text"],
         User = UserEntity.Parse(o["user"].ToString(), userAccountEntity),
         ImageUrl =
             (JObject) o["entities"]["media"] == null
                 ? null
                 : ParseEntities((JObject) o["entities"], "media_url_https"),
         ImageLargeUrl =
             (JObject) o["entities"]["media"] == null
                 ? null
                 : ParseEntities((JObject) o["entities"], "media_url_https") + "?large",
         Media = (JObject) o["entities"]["media"] == null ? null : ParseEntities((JObject) o["entities"], "type")
     };
     if (post.User != null)
     {
         post.IsCreator = post.User.UserID == userAccountEntity.GetUserEntity().UserID;
     }
     return post;
 }
示例#5
0
 public static UserEntity Parse(String json, UserAccountEntity userAccountEntity)
 {
     JObject o = JObject.Parse(json);
     var user = new UserEntity
     {
         CoverImage = (String)o["cover_image_url_https"] ?? string.Empty,
         CreatedAt = (String) o["created_at"] == null ? 0 : FixTime((String) o["created_at"]),
         Description = (String) o["description"] ?? string.Empty,
         FavoritesCount = (String) o["favorites_count"] == null ? 0 : long.Parse((String) o["favorites_count"]),
         FollowersCount = (String) o["followers_count"] == null ? 0 : long.Parse((String) o["followers_count"]),
         FriendsCount = (String) o["friends_count"] == null ? 0 : long.Parse((String) o["friends_count"]),
         IsFollowing =
             (String) o["following"] != null &&
             (!((String) o["following"]).Equals("underdevelopment") && Boolean.Parse((String) o["following"])),
         IsFollowRequest =
             (String) o["follow_request_sent"] != null &&
             (!((String) o["follow_request_sent"]).Equals("underdevelopment") &&
              Boolean.Parse((String) o["follow_request_sent"])),
         IsProtected = (String) o["protected"] != null && Boolean.Parse((String) o["protected"]),
         Location = (String) o["location"] ?? string.Empty,
         Name = Regex.Replace((String) o["name"], @"\t|\n|\r", ""),
         ProfileImage = (String) o["profile_image_url_https"],
         ScreenName = (String) o["screen_name"],
         StatusCount = (String) o["statuses_count"] == null ? 0 : long.Parse((String) o["statuses_count"]),
         URL = (String) o["url"] ?? string.Empty,
         UserID = long.Parse((String) o["id"])
     };
     user.IsNotFollowing = !user.IsFollowing;
     if (userAccountEntity == null || userAccountEntity.GetUserEntity() == null) return user;
     user.IsCurrentUser = user.UserID == userAccountEntity.GetUserEntity().UserID;
     user.IsNotCurrentUser = !user.IsCurrentUser;
     return user;
 }