コード例 #1
0
        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)));
            }
        }
コード例 #2
0
 protected LocalStoragePostSource(string name, DirectoryInfo directory, bool supportsDelete, RecentPostRequest defaultRequest)
 {
     _name           = name;
     _directory      = directory;
     _supportsDelete = supportsDelete;
     _defaultRequest = defaultRequest;
 }
コード例 #3
0
        public PostInfo[] GetPages(RecentPostRequest request)
        {
            if (!SupportsPages)
            {
                throw new InvalidOperationException("This post source does not support pages!");
            }

            return(GetPosts(request, true));
        }
コード例 #4
0
        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);
            }
        }
コード例 #5
0
        public override bool Equals(object obj)
        {
            RecentPostRequest equalTo = obj as RecentPostRequest;

            return(equalTo != null && NumberOfPosts == equalTo.NumberOfPosts);
        }
コード例 #6
0
 public RecentPostCapabilities(RecentPostRequest[] validRequests, RecentPostRequest defaultRequest)
 {
     _validRequests  = validRequests;
     _defaultRequest = defaultRequest;
 }
コード例 #7
0
 public PostInfo[] GetRecentPosts(RecentPostRequest request)
 {
     return(PostEditorFile.GetRecentPosts(_directory, request));
 }
コード例 #8
0
 public PostInfo[] GetPages(RecentPostRequest request)
 {
     throw new NotSupportedException("Pages are not suppported for this post source!");
 }
コード例 #9
0
 public PostInfo[] GetRecentPosts(RecentPostRequest request)
 {
     return(GetPosts(request, false));
 }
コード例 #10
0
 public PostInfo[] GetRecentPosts(RecentPostRequest request)
 {
     return PostEditorFile.GetRecentPosts(_directory, request);
 }
コード例 #11
0
 public RecentPostCapabilities(RecentPostRequest[] validRequests, RecentPostRequest defaultRequest)
 {
     _validRequests = validRequests;
     _defaultRequest = defaultRequest;
 }
コード例 #12
0
 public PostInfo[] GetPages(RecentPostRequest request)
 {
     throw new NotSupportedException("Pages are not suppported for this post source!");
 }
コード例 #13
0
 protected LocalStoragePostSource(string name, DirectoryInfo directory, bool supportsDelete, RecentPostRequest defaultRequest)
 {
     _name = name;
     _directory = directory;
     _supportsDelete = supportsDelete;
     _defaultRequest = defaultRequest;
 }
コード例 #14
0
        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));
            }
        }
コード例 #15
0
        public PostInfo[] GetPages(RecentPostRequest request)
        {
            if (!SupportsPages)
                throw new InvalidOperationException("This post source does not support pages!");

            return GetPosts(request, true);
        }
コード例 #16
0
 public PostInfo[] GetRecentPosts(RecentPostRequest request)
 {
     return GetPosts(request, false);
 }