コード例 #1
0
        public List<JarbooPage> GetBySpecifiction(PageSpecification specification)
        {
            var result = new List<JarbooPage>();
            var url = string.Format("{0}{1}posts_per_page={2}&offset={3}", DomainBase, MultipleApiBase, specification.Take, specification.Skip);
            try
            {
                using (var client = new WebClient())
                {
                    var data = client.DownloadString(url);

                    var blog = JsonConvert.DeserializeObject<WordpressBlog>(data);

                    result.AddRange(blog.posts.Select(s => new JarbooPage
                    {
                        Content = s.content,
                        DateCreated = s.date,
                        Title = s.title,
                        Slug = s.slug,
                        Pages = blog.pages,
                        TotalCount = blog.count_total
                    }));

                    return result;
                }
            }
            catch (Exception)
            {
                return result;
            }
        }
コード例 #2
0
ファイル: Host.cs プロジェクト: WaffleSquirrel/More
        static partial void AddPlatformSpecificConventions( ConventionBuilder builder )
        {
            var assembly = new PublicKeyTokenSpecification( typeof( Host ) );
            var page = new PageSpecification();
            var userControl = new UserControlSpecification();

            builder.ForTypesMatching( page.IsSatisfiedBy ).Export().Export<Page>().ExportInterfaces( assembly.IsSatisfiedBy ).ImportProperties( p => p != null && p.Name == "Model" );
            builder.ForTypesMatching( userControl.IsSatisfiedBy ).Export().ExportInterfaces( assembly.IsSatisfiedBy ).ImportProperties( p => p != null && p.Name == "Model" );
            AddWinRTSpecificConventions( builder );
        }
コード例 #3
0
        public ActionResult RecentlyPosts()
        {
            const int articlesPerPage = 10;
            var spec = new PageSpecification
            {
                Take = articlesPerPage,
                Skip = 0
            };

            var blogs = _postService.GetBySpecifiction(spec);
            return PartialView("_RecentlyPosts", blogs);
        }
コード例 #4
0
        public ActionResult Blogs(int page = 1)
        {
            const int articlesPerPage = 10;
            var spec = new PageSpecification
            {
                Take = articlesPerPage,
                Skip = (page - 1) * articlesPerPage
            };

            var blogs = _postService.GetBySpecifiction(spec);

            ViewBag.Page = page;

            return View(blogs);
        }