Ejemplo n.º 1
0
        /// <summary>
        /// 获取文章内容
        /// </summary>
        /// <param name="page_index"></param>
        /// <param name="page_size"></param>
        /// <returns></returns>
        public async static Task <List <BlogComment> > GetBlogCommentsAsync(string id, int pageIndex, int pageSize)
        {
            try
            {
                string url = string.Format(WcfApiUrlConstants.GetBlogComments, id, pageIndex, pageSize);
                string xml = await HttpHelper.GetAsync(url);

                xml = xml.Replace(Constants.XmlNameSpace, "");//.Replace("&", "");
                xml = RemoveInvalidCharacter(xml);
                List <BlogComment> blogComments = new List <BlogComment>();
                XElement           xElement     = XElement.Parse(xml);
                int i = 1;
                foreach (XElement entry in xElement.Elements("entry"))
                {
                    BlogComment blogComment = BlogComment.Load(entry, i++);
                    blogComments.Add(blogComment);
                }
                return(blogComments);
            }
            catch (Exception exception)
            {
                System.Diagnostics.Debug.WriteLine(exception.Message);
                return(null);
            }
        }