Ejemplo n.º 1
0
        /// <summary>
        /// Reload information for the thread. This gets all the post information from the API, updates the cache in-place,
        /// and returns a new list of all the posts in the thread.
        /// </summary>
        /// <returns>A list of the posts in the thread.</returns>
        public async Task<List<Post>> GetPostsAsync()
        {
            using (Stream s = await RequestManager.Current.GetStreamAsync(new Uri("http://a.4cdn.org/" + Board.Name + "/thread/" + Number + ".json")))
            {
                DataContractJsonSerializer dcjs = new DataContractJsonSerializer(typeof(APIThread));

                APIThread t = await dcjs.ReadObjectAsync<APIThread>(s);

                List<Post> posts = new List<Post>();
                foreach (APIPost p in t.Posts)
                {
                    Merge(p);
                    posts.Add(Posts[p.Number]);
                }

                return posts;
            }
        }