本文整理汇总了C#中BlogML.Xml.BlogMLPost类的典型用法代码示例。如果您正苦于以下问题:C# BlogMLPost类的具体用法?C# BlogMLPost怎么用?C# BlogMLPost使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BlogMLPost类属于BlogML.Xml命名空间,在下文中一共展示了BlogMLPost类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Process
public void Process(BlogMLPost postml)
{
Log.Debug("Fetching trackbacks.");
using (var query = new OxiteReader("SELECT * FROM oxite_Trackback WHERE PostID='" + postml.ID + "'"))
{
var trackbacks = query.Execute();
foreach (var track in trackbacks)
{
var trackbackml = new BlogMLTrackback
{
Approved = false, /* Oxite has no trackback approving */
DateCreated = track.CreatedDate,
DateModified = track.ModifiedDate,
ID = track.TrackbackID.ToString(),
Title = track.Title,
Url = track.Url
};
postml.Trackbacks.Add(trackbackml);
}
}
Log.DebugFormat("Finished adding {0} trackbacks.", postml.Trackbacks.Count);
}
开发者ID:HEskandari,项目名称:OxiteMigrator,代码行数:26,代码来源:TrackbackWorker.cs
示例2: Process
public void Process(BlogMLPost postml)
{
Log.DebugFormat("Fetching anonymous comments for PostID {0}", postml.ID);
using (var query = new OxiteReader("SELECT * FROM oxite_CommentAnonymous A, oxite_Comment B WHERE A.CommentID = B.CommentID AND PostID='" + postml.ID + "'"))
{
var comments = query.Execute();
foreach (var comment in comments)
{
var commentml = new BlogMLComment
{
ID = comment.CommentID.ToString(),
DateCreated = comment.CreatedDate,
DateModified = comment.ModifiedDate,
Approved = comment.State == (int)RecordStates.Normal,
UserName = comment.Name,
UserUrl = comment.Url,
UserEMail = comment.Email,
Content = new BlogMLContent
{
ContentType = ContentTypes.Html,
Text = comment.Body
}
};
postml.Comments.Add(commentml);
}
}
Log.DebugFormat("Finished adding anonymous comments.");
}
开发者ID:HEskandari,项目名称:OxiteMigrator,代码行数:32,代码来源:AnonymousCommentWorker.cs
示例3: 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
示例4: 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
示例5: ConvertBlogPost_WithNullPostNameButWithPostUrlContainingBlogSpotDotCom_UsesLastSegmentAsEntryName
public void ConvertBlogPost_WithNullPostNameButWithPostUrlContainingBlogSpotDotCom_UsesLastSegmentAsEntryName()
{
// arrange
var post = new BlogMLPost { PostUrl = "http://example.blogspot.com/2003/07/the-last-segment.html" };
var mapper = new BlogMLImportMapper();
// act
Entry entry = mapper.ConvertBlogPost(post, new BlogMLBlog(), null);
// assert
Assert.AreEqual("the-last-segment", entry.EntryName);
}
开发者ID:ChrisPelatari,项目名称:SubText,代码行数:12,代码来源:BlogMLImportMapperTests.cs
示例6: WritePostCategories
protected void WritePostCategories(BlogMLPost.CategoryReferenceCollection categoryRefs)
{
if (categoryRefs.Count > 0)
{
WriteStartCategories();
foreach (BlogMLCategoryReference categoryRef in categoryRefs)
{
WriteCategoryReference(categoryRef.Ref);
}
WriteEndElement();
}
}
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:12,代码来源:BlogMLWriter.cs
示例7: CreatePostInstance
public static BlogMLPost CreatePostInstance(string id, string title, string url, bool approved, string content, DateTime dateCreated, DateTime dateModified)
{
BlogMLPost post = new BlogMLPost();
post.ID = id;
post.Title = title;
post.PostUrl = url;
post.Approved = approved;
post.Content = new BlogMLContent();
post.Content.Text = content;
post.DateCreated = dateCreated;
post.DateModified = dateModified;
return post;
}
开发者ID:ayende,项目名称:Subtext,代码行数:13,代码来源:ObjectHydrator.cs
示例8: 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
示例9: ConvertBlogPost_WithDateModified_ReturnsItAsDatePublishedUtc
public void ConvertBlogPost_WithDateModified_ReturnsItAsDatePublishedUtc()
{
// arrange
DateTime utcNow = DateTime.ParseExact("2009/08/15 11:00 PM", "yyyy/MM/dd hh:mm tt", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);
var post = new BlogMLPost { Approved = true, DateModified = utcNow };
var blog = new Mock<Blog>();
var mapper = new BlogMLImportMapper();
// act
var entry = mapper.ConvertBlogPost(post, new BlogMLBlog(), blog.Object);
// assert
Assert.AreEqual(utcNow, entry.DatePublishedUtc);
}
开发者ID:rhoadsce,项目名称:Subtext,代码行数:14,代码来源:BlogMLImportMapperTests.cs
示例10: ConvertBlogPost_WithApprovedPost_SetsAppropriatePublishPropertiesOfEntry
public void ConvertBlogPost_WithApprovedPost_SetsAppropriatePublishPropertiesOfEntry()
{
// arrange
var post = new BlogMLPost {Approved = true};
var mapper = new BlogMLImportMapper();
// act
var entry = mapper.ConvertBlogPost(post, new BlogMLBlog(), null);
// assert
Assert.IsTrue(entry.IsActive);
Assert.IsTrue(entry.DisplayOnHomePage);
Assert.IsTrue(entry.IncludeInMainSyndication);
Assert.IsTrue(entry.IsAggregated);
}
开发者ID:ChrisPelatari,项目名称:SubText,代码行数:15,代码来源:BlogMLImportMapperTests.cs
示例11: 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
示例12: 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("noneofyourbusiness[email protected]", entry.Email);
}
开发者ID:ChrisPelatari,项目名称:SubText,代码行数:17,代码来源:BlogMLImportMapperTests.cs
示例13: 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
示例14: Process
public void Process(BlogMLPost postml)
{
Log.DebugFormat("Setting up category references on post {0}", postml.ID);
using (var query = new OxiteReader("SELECT * FROM oxite_Post A, oxite_PostTagRelationship B WHERE A.PostID=B.PostID AND A.PostID='" + postml.ID + "'"))
{
var tagRefs = query.Execute();
foreach(var tag in tagRefs)
{
var commentRef = new BlogMLCategoryReference
{
Ref = tag.TagID.ToString()
};
postml.Categories.Add(commentRef);
}
}
}
开发者ID:HEskandari,项目名称:OxiteMigrator,代码行数:19,代码来源:CategoryReferenceWorker.cs
示例15: 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
示例16: 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
示例17: Write_WithBlogContainingBase64EncodedPosts_WritesPostsToWriterAsBase64Encoded
public void Write_WithBlogContainingBase64EncodedPosts_WritesPostsToWriterAsBase64Encoded()
{
// 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 { Content = BlogMLContent.Create("<p>This is a Test</p>", ContentTypes.Base64) };
var posts = new List<BlogMLPost> { post };
blog.Posts.Add(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();
Console.WriteLine(Convert.ToBase64String(Encoding.UTF8.GetBytes("<p>This is a Test</p>")));
Assert.Contains(output, @"<content type=""base64""><![CDATA[PHA+VGhpcyBpcyBhIFRlc3Q8L3A+]]></content>");
}
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:23,代码来源:BlogMLWriterTests.cs
示例18: Import_WithEmbeddedAttachments_CreatesFilesForAttachmentsAndRewritesBlogPost
public void Import_WithEmbeddedAttachments_CreatesFilesForAttachmentsAndRewritesBlogPost()
{
// arrange
var data = new byte[] { 1, 2, 3 };
var attachment = new BlogMLAttachment { Url = "http://old.example.com/images/my-mug.jpg", Embedded = true, Data = data };
var post = new BlogMLPost { Content = new BlogMLContent { Text = @"<img src=""http://old.example.com/images/my-mug.jpg"" />" } };
post.Attachments.Add(attachment);
var blog = new BlogMLBlog();
blog.Posts.Add(post);
var repository = new Mock<IBlogImportRepository>();
repository.Setup(r => r.GetAttachmentDirectoryPath()).Returns(ImageDirectory + "/wlw");
repository.Setup(r => r.GetAttachmentDirectoryUrl()).Returns("http://example.com/images/wlw/");
var service = new BlogImportService(repository.Object);
// act
service.Import(blog);
// assert
Assert.IsTrue(File.Exists(Path.Combine(ImageDirectory, @"wlw\my-mug.jpg")));
Assert.AreEqual(@"<img src=""http://example.com/images/wlw/my-mug.jpg"" />", post.Content.UncodedText);
}
开发者ID:ChrisPelatari,项目名称:SubText,代码行数:21,代码来源:BlogImportServiceTests.cs
示例19: Import_WithCreateTrackbackThrowingException_DoesNotPropagateException
public void Import_WithCreateTrackbackThrowingException_DoesNotPropagateException()
{
// arrange
var blog = new BlogMLBlog();
var post = new BlogMLPost();
post.Trackbacks.Add(new BlogMLTrackback());
blog.Posts.Add(post);
var repository = new Mock<IBlogImportRepository>();
repository.Setup(r => r.CreateTrackback(It.IsAny<BlogMLTrackback>(), It.IsAny<string>())).Throws(new InvalidOperationException());
var service = new BlogImportService(repository.Object);
// act, assert
service.Import(blog);
}
开发者ID:ChrisPelatari,项目名称:SubText,代码行数:14,代码来源:BlogImportServiceTests.cs
示例20: Import_WithBlogPostHavingTrackback_CreatesTrackbackUsingPostId
public void Import_WithBlogPostHavingTrackback_CreatesTrackbackUsingPostId()
{
// arrange
var blog = new BlogMLBlog();
var post = new BlogMLPost();
var trackback = new BlogMLTrackback();
post.Trackbacks.Add(trackback);
blog.Posts.Add(post);
var repository = new Mock<IBlogImportRepository>();
repository.Setup(r => r.CreateBlogPost(blog, post)).Returns("98053");
bool trackbackCreated = false;
repository.Setup(r => r.CreateTrackback(trackback, "98053")).Callback(() => trackbackCreated = true);
var service = new BlogImportService(repository.Object);
// act
service.Import(blog);
// assert
Assert.IsTrue(trackbackCreated);
}
开发者ID:ChrisPelatari,项目名称:SubText,代码行数:20,代码来源:BlogImportServiceTests.cs
注:本文中的BlogML.Xml.BlogMLPost类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论