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