Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="tumblrPostType"></param>
        /// <returns></returns>
        public HashSet <TumblrPost> GetPostListFromDoc(TumblrPostType tumblrPostType)
        {
            try
            {
                HashSet <TumblrPost> postList = new HashSet <TumblrPost>();

                if (JsonDocument != null && JsonDocument.response != null && JsonDocument.response.posts != null)
                {
                    JArray            jPostArray = JsonDocument.response.posts;
                    HashSet <dynamic> jPostList  = jPostArray.ToObject <HashSet <dynamic> >();

                    foreach (dynamic jPost in jPostList)
                    {
                        TumblrPost post = new TumblrPost();

                        switch (tumblrPostType)
                        {
                        case TumblrPostType.Photo:
                            PostHelper.GeneratePhotoPost(ref post, jPost, ImageSize);
                            break;

                        default:
                            PostHelper.IncludeCommonPostFields(ref post, jPost);
                            break;
                        }

                        postList.Add(post);
                    }
                }

                return(postList);
            }
            catch
            {
                return(null);
            }
        }