本文整理汇总了C#中BlogML.Xml.BlogMLPost类的典型用法代码示例。如果您正苦于以下问题:C# BlogMLPost类的具体用法?C# BlogMLPost怎么用?C# BlogMLPost使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BlogMLPost类属于BlogML.Xml命名空间,在下文中一共展示了BlogMLPost类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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.");
}
示例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;
}
示例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>");
}
示例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);
}
示例6: WritePostCategories
protected void WritePostCategories(BlogMLPost.CategoryReferenceCollection categoryRefs)
{
if (categoryRefs.Count > 0)
{
WriteStartCategories();
foreach (BlogMLCategoryReference categoryRef in categoryRefs)
{
WriteCategoryReference(categoryRef.Ref);
}
WriteEndElement();
}
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
}
示例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));
}