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 CategoryReference AssembleCategoryReference(XElement referenceElement) { CategoryReference reference = new CategoryReference(); reference.ID = referenceElement.Attribute("nicename").Value.Trim(); reference.Title = referenceElement.Value.Trim(); return reference; }