• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# BlogMLBlog类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中BlogMLBlog的典型用法代码示例。如果您正苦于以下问题:C# BlogMLBlog类的具体用法?C# BlogMLBlog怎么用?C# BlogMLBlog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BlogMLBlog类属于命名空间,在下文中一共展示了BlogMLBlog类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ConvertBlogPost

        public Entry ConvertBlogPost(BlogMLPost post, BlogMLBlog blogMLBlog, Blog blog)
        {
            DateTime dateModified = blog != null ? blog.TimeZone.FromUtc(post.DateModified) : post.DateModified;
            DateTime dateCreated = blog != null ? blog.TimeZone.FromUtc(post.DateCreated) : post.DateCreated;

            var newEntry = new Entry((post.PostType == BlogPostTypes.Article) ? PostType.Story : PostType.BlogPost)
            {
                Title = GetTitleFromPost(post).Left(BlogPostTitleMaxLength),
                DateCreated = dateCreated,
                DateModified = dateModified,
                DateSyndicated = post.Approved ? dateModified : DateTime.MaxValue,
                Body = post.Content.UncodedText,
                IsActive = post.Approved,
                DisplayOnHomePage = post.Approved,
                IncludeInMainSyndication = post.Approved,
                IsAggregated = post.Approved,
                AllowComments = true,
                Description = post.HasExcerpt ? post.Excerpt.UncodedText: null
            };

            if(!string.IsNullOrEmpty(post.PostName))
            {
                newEntry.EntryName = post.PostName;
            }
            else
            {
                SetEntryNameForBlogspotImport(post, newEntry);
            }

            SetEntryAuthor(post, newEntry, blogMLBlog);

            SetEntryCategories(post, newEntry, blogMLBlog);
            return newEntry;
        }
开发者ID:ChrisPelatari,项目名称:SubText,代码行数:34,代码来源:BlogMLImportMapper.cs


示例2: Process

        public void Process(BlogMLBlog blogml)
        {
            Log.Info("Fetching Tags.");

            using (var query = new OxiteReader("SELECT * FROM oxite_Tag"))
            {
                var tags = query.Execute();

                foreach (var tag in tags)
                {
                    var category = new BlogMLCategory
                    {
                        Approved = true,
                        DateCreated = tag.CreatedDate,
                        DateModified = tag.CreatedDate,
                        Description = tag.TagName,
                        ID = tag.TagID.ToString(),
                        ParentRef = tag.TagID.ToString() == tag.ParentTagID.ToString() ? "0" : tag.ParentTagID.ToString(),
                        Title = tag.TagName
                    };

                    blogml.Categories.Add(category);
                }
            }

            Log.InfoFormat("Finished adding {0} tags.", blogml.Categories.Count);
        }
开发者ID:HEskandari,项目名称:OxiteMigrator,代码行数:27,代码来源:TagWorker.cs


示例3: Write_WithBlogContainingEmbeddedAttachmentsWithComments_WritesPostAttachmentsToWriter

        public void Write_WithBlogContainingEmbeddedAttachmentsWithComments_WritesPostAttachmentsToWriter()
        {
            // arrange
            var stringWriter = new StringWriter();
            var xmlWriter = new XmlTextWriter(stringWriter) {Formatting = Formatting.Indented};
            var source = new Mock<IBlogMLSource>();
            var dateTime = DateTime.ParseExact("20090123", "yyyyMMdd", CultureInfo.InvariantCulture);
            var blog = new BlogMLBlog { Title = "Subtext Blog", RootUrl = "http://subtextproject.com/", SubTitle = "A test blog", DateCreated = dateTime };
            source.Setup(s => s.GetBlog()).Returns(blog);
            var post = new BlogMLPost { Title = "This is a blog post" };
            var attachment = new BlogMLAttachment
            {
                Data = new byte[] {1, 2, 3, 4, 5},
                Path = @"c:\\path-to-attachment.jpg",
                Url = "/foo/path-to-attachment.jpg",
                Embedded = true,
                MimeType = "img/jpeg"
            };
            post.Attachments.Add(attachment);
            var posts = new List<BlogMLPost> { post };

            source.Setup(s => s.GetBlogPosts(false /*embedAttachments*/)).Returns(posts);
            var writer = new BlogMLWriter(source.Object, false /*embedAttachments*/);

            // act
            ((IBlogMLWriter)writer).Write(xmlWriter);

            // assert
            string output = stringWriter.ToString();
            Assert.Contains(output, @"external-uri=""c:\\path-to-attachment.jpg""");
            Assert.Contains(output, @"url=""/foo/path-to-attachment.jpg""");
            Assert.Contains(output, @"mime-type=""img/jpeg""");
            Assert.Contains(output, @"embedded=""true""");
            Assert.Contains(output, @"AQIDBAU=</attachment>");
        }
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:35,代码来源:BlogMLWriterTests.cs


示例4: ImportPostsFromBlog

 void ImportPostsFromBlog(BlogMLBlog blog)
 {
     foreach (BlogMLPost post in blog.Posts) {
         Post importPost = _tasks.ImportPost(_postMapper.MapFrom(post, blog.Categories));
         importPost.Author = _authors.FirstOrDefault();
         importPost.AllowComments = true;
         foreach (BlogMLComment comment in post.Comments) importPost.AddComment(_commentMapper.MapFrom(comment));
     }
 }
开发者ID:lg31415,项目名称:Graphite,代码行数:9,代码来源:BlogMLImporter.cs


示例5: ImportBlogPosts

        void ImportBlogPosts(IDocumentStore store, BlogMLBlog blog)
        {
            Stopwatch sp = Stopwatch.StartNew();

            var usersList = ImportUserList(store, blog);

            importBlogPosts(store, blog, usersList);

            Console.WriteLine(sp.Elapsed);
        }
开发者ID:wheeliemow,项目名称:RaccoonBlog,代码行数:10,代码来源:Program.cs


示例6: ImportAuthorsFromBlog

 void ImportAuthorsFromBlog(BlogMLBlog blog)
 {
     foreach (BlogMLAuthor author in blog.Authors) {
         User user = _users.GetUserByEmail(author.Email) ?? _users.AddUser(new CreateUserDetails {
                                                                                                 Email = author.Email,
                                                                                                 RealName = author.Title,
                                                                                                 Username = author.Email.Split('@')[0]
                                                                                                 });
         _authors.Add(user);
     }
 }
开发者ID:lg31415,项目名称:Graphite,代码行数:11,代码来源:BlogMLImporter.cs


示例7: Process

        public void Process(BlogMLBlog blogml)
        {
            ProcessPosts(blogml);

            foreach(var post in blogml.Posts)
            {
                foreach (var worker in Workers)
                {
                    worker.Process(post);
                }
            }
        }
开发者ID:HEskandari,项目名称:OxiteMigrator,代码行数:12,代码来源:BlogPostWorker.cs


示例8: Migrate

        public void Migrate()
        {
            Log.Info("Starting the export process.");

            var blog = new BlogMLBlog();

            foreach (var worker in Workers)
            {
                worker.Process(blog);
            }

            Log.Info("Finished exporting. All done.");
        }
开发者ID:HEskandari,项目名称:OxiteMigrator,代码行数:13,代码来源:Migrator.cs


示例9: CreateBlogInstance

 public static BlogMLBlog CreateBlogInstance(string title, string subtitle, string rootUrl, string author, string email, DateTime dateCreated)
 {
     BlogMLBlog blog = new BlogMLBlog();
     BlogMLAuthor blogAuthor = new BlogMLAuthor();
     blogAuthor.Title = author;
     blogAuthor.Email = email;
     blog.Authors.Add(blogAuthor);
     blog.Title = title;
     blog.SubTitle = subtitle;
     blog.RootUrl = rootUrl;
     blog.DateCreated = dateCreated;
     return blog;
 }
开发者ID:ayende,项目名称:Subtext,代码行数:13,代码来源:ObjectHydrator.cs


示例10: GetPostCategoryies

 private ICollection<Category> GetPostCategoryies(BlogMLBlog.CategoryCollection categories, BlogMLPost blogMLPost)
 {
     var list = new List<Category>();
     if (blogMLPost == null || blogMLPost.Categories == null) return new Collection<Category>();
     for (int i = 0; i < blogMLPost.Categories.Count; i++)
     {
         string postCategoryId = blogMLPost.Categories[i].Ref;
         list.AddRange(from category in categories
                       where category.ID == postCategoryId
                       select new Category {CategoryName = category.Title});
     }
     return list;
 }
开发者ID:avington,项目名称:aviblog,代码行数:13,代码来源:BlogMLMappingService.cs


示例11: Process

        public void Process(BlogMLBlog blogml)
        {
            var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ExportFileName);
            Log.InfoFormat("Creating BlogML export file in {0}", path);

            using (var output = new FileStream(path, FileMode.Create))
            {
                Log.Info("Serializing Blog data into file.");
                BlogMLSerializer.Serialize(output, blogml);
            }

            Log.Info("Finished writing the export file.");
        }
开发者ID:HEskandari,项目名称:OxiteMigrator,代码行数:13,代码来源:BlogMLExportWorker.cs


示例12: Export

    public BlogMLBlog Export(Id entryCollectionId, Id pagesCollectionId, Id mediaCollectionId)
    {
      LogService.Info("Beginning export of collection with Id='{0}'", entryCollectionId);
      BlogMLBlog blog = new BlogMLBlog();
      AppService appSvc = AtomPubService.GetService();

      AppCollection coll = appSvc.GetCollection(entryCollectionId);

      blog.Title = coll.Title.Text;
      if (coll.Subtitle != null) blog.SubTitle = coll.Subtitle.Text;
      blog.RootUrl = coll.Href.ToString();

      //extended properties
      blog.ExtendedProperties.Add(new BlogML.Pair<string, string>("CommentModeration", AuthorizeService.IsAuthorized(AuthRoles.Anonymous, coll.Id.ToScope(),
        AuthAction.ApproveAnnotation) ? "Anonymous" : "Authenticated"));
      blog.ExtendedProperties.Add(new BlogML.Pair<string, string>("SendTrackback", new BlogAppCollection(coll).TrackbacksOn ? "Yes" : "No"));

      foreach (BlogMLCategory cat in coll.AllCategories.Select(c => new BlogMLCategory()
      {
        ID = c.Term,
        Approved = true,
        DateCreated = DateTime.UtcNow,
        DateModified = DateTime.UtcNow,
        Title = c.ToString()
      })) { blog.Categories.Add(cat); }

      IPagedList<AtomEntry> entries = null;
      int page = 0;
      do
      {
        entries = AtomPubService.GetEntries(new EntryCriteria() { WorkspaceName = entryCollectionId.Workspace, CollectionName = entryCollectionId.Collection, Authorized = true },
        page, 100); page++;
        foreach (AtomEntry entry in entries)
        {
          try
          {
            LogService.Info("Processing entry with ID='{0}'", entry.Id);
            AddEntry(entry, blog);
          }
          catch (Exception ex)
          {
            LogService.Error(ex);
          }
        }
      } while (entries.PageIndex < entries.PageCount);

      LogService.Info("Finished export!");
      return blog;
    }
开发者ID:erikzaadi,项目名称:atomsitethemes.erikzaadi.com,代码行数:49,代码来源:BlogMLService.cs


示例13: ConvertBlogPost_WithAuthorTitleTooLong_TruncatesTitleToMaxLength

        public void ConvertBlogPost_WithAuthorTitleTooLong_TruncatesTitleToMaxLength()
        {
            // arrange
            var title = new string('a', 51);
            var blog = new BlogMLBlog();
            blog.Authors.Add(new BlogMLAuthor{ID = "123", Title = title});
            var post = new BlogMLPost();
            post.Authors.Add("123");
            var mapper = new BlogMLImportMapper();

            // act
            Entry entry = mapper.ConvertBlogPost(post, blog, null);

            // assert
            Assert.AreEqual(50, entry.Author.Length);
        }
开发者ID:ChrisPelatari,项目名称:SubText,代码行数:16,代码来源:BlogMLImportMapperTests.cs


示例14: CreateBlogPost_WithEntryPublisher_PublishesBlogPostAndReturnsId

        public void CreateBlogPost_WithEntryPublisher_PublishesBlogPostAndReturnsId()
        {
            // arrange
            var context = new Mock<ISubtextContext>();
            context.Setup(c => c.Blog).Returns(new Blog());
            var entryPublisher = new Mock<IEntryPublisher>();
            entryPublisher.Setup(p => p.Publish(It.IsAny<Entry>())).Returns(310);
            var blog = new BlogMLBlog();
            var post = new BlogMLPost();
            var repository = new BlogImportRepository(context.Object, null, entryPublisher.Object, new BlogMLImportMapper());

            // act
            var id = repository.CreateBlogPost(blog, post);

            // assert
            Assert.AreEqual("310", id);
        }
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:17,代码来源:BlogImportRepositoryTests.cs


示例15: ConvertBlogPost_WithAuthorMatchingBlogAuthor_SetsAuthorNameAndEmail

        public void ConvertBlogPost_WithAuthorMatchingBlogAuthor_SetsAuthorNameAndEmail()
        {
            // arrange
            var blog = new BlogMLBlog();
            blog.Authors.Add(new BlogMLAuthor { ID = "111", Title = "Not-Haacked", Email = "[email protected]"});
            blog.Authors.Add(new BlogMLAuthor { ID = "222", Title = "Haacked", Email = "[email protected]"});
            var post = new BlogMLPost();
            post.Authors.Add("222");
            var mapper = new BlogMLImportMapper();

            // act
            var entry = mapper.ConvertBlogPost(post, blog, null);

            // assert
            Assert.AreEqual("Haacked", entry.Author);
            Assert.AreEqual("[email protected]", entry.Email);
        }
开发者ID:ChrisPelatari,项目名称:SubText,代码行数:17,代码来源:BlogMLImportMapperTests.cs


示例16: CreateCategories_WithBlogHavingCategories_CreatesCategories

        public void CreateCategories_WithBlogHavingCategories_CreatesCategories()
        {
            // arrange
            var context = new Mock<ISubtextContext>();
            context.Setup(c => c.Blog).Returns(new Blog { Id = 123 });
            bool categoryCreated = false;
            context.Setup(c => c.Repository.CreateLinkCategory(It.IsAny<LinkCategory>())).Callback(() => categoryCreated = true);
            var blog = new BlogMLBlog();
            blog.Categories.Add(new BlogMLCategory { Title = "Category Title", ID = "123" });
            var repository = new BlogImportRepository(context.Object, null, null, new BlogMLImportMapper());

            // act
            repository.CreateCategories(blog);

            // assert
            Assert.IsTrue(categoryCreated);
        }
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:17,代码来源:BlogImportRepositoryTests.cs


示例17: Process

        public void Process(BlogMLBlog blogml)
        {
            Log.Info("Fetching Blog information");

            using (var siteQuery = new OxiteReader("SELECT * FROM oxite_Site"))
            using (var areaQuery = new OxiteReader("SELECT * FROM oxite_Area"))
            {
                var blog = siteQuery.Execute().First();
                var area = areaQuery.Execute().First();

                Log.WarnFormat("This version only supports migration from one Blog and one Area.");
                Log.InfoFormat("Migrating '{0}' blog...", blog.SiteDisplayName);

                blogml.RootUrl = string.Format("{0}/{1}", blog.SiteHost, blog.SiteDisplayName);
                blogml.DateCreated = area.CreatedDate;
                blogml.Title = blog.SiteDescription;
                blogml.SubTitle = area.Description;
            }
        }
开发者ID:HEskandari,项目名称:OxiteMigrator,代码行数:19,代码来源:SiteInfoWorker.cs


示例18: Write_WithBlogContainingCategories_WritesCategoriesToWriter

        public void Write_WithBlogContainingCategories_WritesCategoriesToWriter()
        {
            // arrange
            var stringWriter = new StringWriter();
            var xmlWriter = new XmlTextWriter(stringWriter) {Formatting = Formatting.Indented};
            var source = new Mock<IBlogMLSource>();
            var dateTime = DateTime.ParseExact("20090123", "yyyyMMdd", CultureInfo.InvariantCulture);
            var blog = new BlogMLBlog { Title = "Subtext Blog", RootUrl = "http://subtextproject.com/", SubTitle = "A test blog", DateCreated = dateTime };
            blog.Categories.Add(new BlogMLCategory { ID = "221", Title = "Test Category"});
            source.Setup(s => s.GetBlog()).Returns(blog);
            var writer = new BlogMLWriter(source.Object, false /*embedAttachments*/);

            // act
            ((IBlogMLWriter)writer).Write(xmlWriter);

            // assert
            string output = stringWriter.ToString();
            Assert.Contains(output, @"<category id=""221""");
            Assert.Contains(output, @"<title type=""text""><![CDATA[Test Category]]></title>");
        }
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:20,代码来源:BlogMLWriterTests.cs


示例19: CreateBlogPost_WithEntryPublisher_RemovesKeywordExpander

        public void CreateBlogPost_WithEntryPublisher_RemovesKeywordExpander()
        {
            // arrange
            var context = new Mock<ISubtextContext>();
            context.Setup(c => c.Blog).Returns(new Blog());
            context.Setup(c => c.Repository.Create(It.IsAny<Entry>(), It.IsAny<IEnumerable<int>>()));
            var transformation = new CompositeTextTransformation();
            var searchengine = new Mock<IIndexingService>();
            var entryPublisher = new EntryPublisher(context.Object, transformation, null, searchengine.Object);
            var keywordExpander = new KeywordExpander((IEnumerable<KeyWord>)null);
            transformation.Add(keywordExpander);
            var blog = new BlogMLBlog() { Title = "MyBlog" };
            var post = new BlogMLPost();
            var repository = new BlogImportRepository(context.Object, null, entryPublisher, new BlogMLImportMapper());

            // act
            repository.CreateBlogPost(blog, post);

            // assert
            Assert.IsFalse(transformation.Contains(keywordExpander));
        }
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:21,代码来源:BlogImportRepositoryTests.cs


示例20: ProcessPosts

        private void ProcessPosts(BlogMLBlog blogml)
        {
            Log.Info("Fetching blog posts.");

            using (var query = new OxiteReader("SELECT * FROM oxite_Post"))
            {
                var posts = query.Execute();

                foreach (var post in posts)
                {
                    var postml = new BlogMLPost
                    {
                        Content = new BlogMLContent
                        {
                            ContentType = ContentTypes.Html,
                            Text = post.Body
                        },
                        Excerpt = new BlogMLContent
                        {
                            ContentType = ContentTypes.Html,
                            Text = post.BodyShort
                        },
                        Approved = post.State == (int)RecordStates.Normal,
                        DateCreated = post.CreatedDate,
                        DateModified = post.ModifiedDate,
                        HasExcerpt = !string.IsNullOrWhiteSpace(post.BodyShort),
                        ID = post.PostID.ToString(),
                        PostName = post.Title,
                        PostType = BlogPostTypes.Normal,
                        PostUrl = post.Slug,
                        Title = post.Title,
                    };

                    blogml.Posts.Add(postml);
                }

                Log.InfoFormat("Finished adding {0} posts.", blogml.Posts.Count);
            }
        }
开发者ID:HEskandari,项目名称:OxiteMigrator,代码行数:39,代码来源:BlogPostWorker.cs



注:本文中的BlogMLBlog类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# BlogPost类代码示例发布时间:2022-05-24
下一篇:
C# Blog类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap