private PostInfo[] GetPosts(RecentPostRequest request, bool getPages) { using (Blog blog = new Blog(_blogId)) { if (getPages) { _blogPosts = blog.GetPages(request.NumberOfPosts); } else { _blogPosts = blog.GetRecentPosts(request.NumberOfPosts, false); } ArrayList recentPosts = new ArrayList(); foreach (BlogPost blogPost in _blogPosts) { PostInfo postInfo = new PostInfo(); postInfo.Id = blogPost.Id; postInfo.IsPage = blogPost.IsPage; postInfo.Title = blogPost.Title; postInfo.Permalink = blogPost.Permalink; postInfo.BlogId = blog.Id; postInfo.BlogName = blog.Name; postInfo.BlogPostId = blogPost.Id; postInfo.Contents = blogPost.Contents; postInfo.DateModified = blogPost.DatePublished; recentPosts.Add(postInfo); } return((PostInfo[])recentPosts.ToArray(typeof(PostInfo))); } }
protected LocalStoragePostSource(string name, DirectoryInfo directory, bool supportsDelete, RecentPostRequest defaultRequest) { _name = name; _directory = directory; _supportsDelete = supportsDelete; _defaultRequest = defaultRequest; }
public PostInfo[] GetPages(RecentPostRequest request) { if (!SupportsPages) { throw new InvalidOperationException("This post source does not support pages!"); } return(GetPosts(request, true)); }
public static PostInfo[] GetRecentPosts(DirectoryInfo directory, RecentPostRequest request) { try { ArrayList blogPosts = new ArrayList(); FileInfo[] files = directory.GetFiles("*" + Extension); Array.Sort(files, new FileInfoByModifiedDateComparer()); int filesReturned = 0; foreach (FileInfo file in files) { // check for exceeding maximum number of posts if (!request.AllPosts && filesReturned++ >= request.NumberOfPosts) break; try { // get post blogPosts.Add(GetPostInfo(file)); } catch (Exception e) { Trace.WriteLine(String.Format(CultureInfo.InvariantCulture, "Unexpected exception getting Recent post info [{0}]:{1}", file.Name, e.ToString())); } } return (PostInfo[])blogPosts.ToArray(typeof(PostInfo)); } catch (Exception ex) { throw PostEditorStorageException.Create(ex); } }
public override bool Equals(object obj) { RecentPostRequest equalTo = obj as RecentPostRequest; return(equalTo != null && NumberOfPosts == equalTo.NumberOfPosts); }
public RecentPostCapabilities(RecentPostRequest[] validRequests, RecentPostRequest defaultRequest) { _validRequests = validRequests; _defaultRequest = defaultRequest; }
public PostInfo[] GetRecentPosts(RecentPostRequest request) { return(PostEditorFile.GetRecentPosts(_directory, request)); }
public PostInfo[] GetPages(RecentPostRequest request) { throw new NotSupportedException("Pages are not suppported for this post source!"); }
public PostInfo[] GetRecentPosts(RecentPostRequest request) { return(GetPosts(request, false)); }
public PostInfo[] GetRecentPosts(RecentPostRequest request) { return PostEditorFile.GetRecentPosts(_directory, request); }
private PostInfo[] GetPosts(RecentPostRequest request, bool getPages) { using (Blog blog = new Blog(_blogId)) { if (getPages) _blogPosts = blog.GetPages(request.NumberOfPosts); else _blogPosts = blog.GetRecentPosts(request.NumberOfPosts, false); ArrayList recentPosts = new ArrayList(); foreach (BlogPost blogPost in _blogPosts) { PostInfo postInfo = new PostInfo(); postInfo.Id = blogPost.Id; postInfo.IsPage = blogPost.IsPage; postInfo.Title = blogPost.Title; postInfo.Permalink = blogPost.Permalink; postInfo.BlogId = blog.Id; postInfo.BlogName = blog.Name; postInfo.BlogPostId = blogPost.Id; postInfo.Contents = blogPost.Contents; postInfo.DateModified = blogPost.DatePublished; recentPosts.Add(postInfo); } return (PostInfo[])recentPosts.ToArray(typeof(PostInfo)); } }
public PostInfo[] GetPages(RecentPostRequest request) { if (!SupportsPages) throw new InvalidOperationException("This post source does not support pages!"); return GetPosts(request, true); }
public PostInfo[] GetRecentPosts(RecentPostRequest request) { return GetPosts(request, false); }