private void GetPosts(Blog blog, BlogMLBlog blogMLBlog) { foreach (var blogMLPost in blogMLBlog.Posts) { Post post = new Post(); post.ID = blogMLPost.ID; post.HasExcerpt = blogMLPost.HasExcerpt; if (post.HasExcerpt) post.Excerpt = new Content { Type = blogMLPost.Excerpt.ContentType.ToString().ToLowerInvariant(), Value = blogMLPost.Excerpt.Text }; foreach (BlogMLAttachment blogMLAttachment in blogMLPost.Attachments) { Attachment attachment = new Attachment(); attachment.Embedded = blogMLAttachment.Embedded; attachment.Value = blogMLAttachment.Data; attachment.MimeType = blogMLAttachment.MimeType; attachment.ExternalURI = blogMLAttachment.Path; attachment.URL = blogMLAttachment.Url; post.Attachments.AttachmentList.Add(attachment); } foreach (BlogMLAuthorReference blogMLAuthor in blogMLPost.Authors) { AuthorReference authorReference = new AuthorReference(); authorReference.ID = blogMLAuthor.Ref; post.Authors.AuthorReferenceList.Add(authorReference); } foreach (BlogMLCategoryReference blogMLCategory in blogMLPost.Categories) { CategoryReference categoryReference = new CategoryReference(); categoryReference.ID = blogMLCategory.Ref; post.Categories.CategoryReferenceList.Add(categoryReference); } foreach (BlogMLComment blogMLComment in blogMLPost.Comments) { Comment comment = new Comment(); comment.ID = blogMLComment.ID; comment.Approved = blogMLComment.Approved; comment.Content = new Content { Type = blogMLComment.Content.ContentType.ToString().ToLowerInvariant(), Value = blogMLComment.Content.Text }; comment.DateCreated = blogMLComment.DateCreated; comment.DateModified = blogMLComment.DateModified; comment.Title = blogMLComment.Title; comment.UserEmail = blogMLComment.UserEMail; comment.UserName = blogMLComment.UserName; comment.UserURL = blogMLComment.UserUrl; post.Comments.CommentList.Add(comment); } // hmm do I care? //foreach (BlogMLTrackback blogMLTrackback in blogMLPost.Trackbacks) { // Trackback trackback = new Trackback(); // trackback.ID = blogMLTrackback.ID; // trackback.Approved = blogMLTrackback.Approved; // trackback.DateCreated = blogMLTrackback.DateCreated; // trackback.DateModified = blogMLTrackback.DateModified; // trackback.Title = blogMLTrackback.Title; // trackback.Url = blogMLTrackback.Url; //} post.Approved = blogMLPost.Approved; post.Content = new Content { Type = blogMLPost.Content.ContentType.ToString().ToLowerInvariant(), Value = blogMLPost.Content.Text }; post.DateCreated = blogMLPost.DateCreated; post.DateModified = blogMLPost.DateModified; post.HasExcerpt = blogMLPost.HasExcerpt; if (post.HasExcerpt) post.Excerpt = new Content { Type = blogMLPost.Excerpt.ContentType.ToString().ToLowerInvariant(), Value = blogMLPost.Excerpt.Text }; post.PostName = new Title {Type = Content.TypeHTML, Value = blogMLPost.PostName}; post.PostUrl = blogMLPost.PostUrl; post.Title = blogMLPost.Title; post.Type = blogMLPost.PostType.ToString(); post.Views = blogMLPost.Views; blog.Posts.PostList.Add(post); } }
internal static Comment AssembleComment(WordpressNamespaces namespaces, XElement commentElement) { Comment comment = new Comment(); // Node (parent) properties. comment.ID = commentElement.WordpressElement(namespaces, "comment_id").Value; comment.Title = comment.ID; comment.DateCreated = DateTime.Parse(commentElement.WordpressElement(namespaces, "comment_date_gmt").Value); comment.Content = new Content(); comment.Content.Type = Content.TypeHTML; comment.Content.Value = ((XCData)commentElement.WordpressElement(namespaces, "comment_content").FirstNode).Value; comment.UserName = ((XCData)commentElement.WordpressElement(namespaces, "comment_author").FirstNode).Value; string email = commentElement.WordpressElement(namespaces, "comment_author_email").Value; if (!string.IsNullOrWhiteSpace(email)) { comment.UserEmail = email; } string url = commentElement.WordpressElement(namespaces, "comment_author_url").Value; if (!string.IsNullOrWhiteSpace(url)) { comment.UserURL = url; } string approved = commentElement.WordpressElement(namespaces, "comment_approved").Value; if (!string.IsNullOrWhiteSpace(approved)) { comment.Approved = approved == "1"; } return comment; }