本文整理汇总了C#中OpenLiveWriter.Extensibility.BlogClient.BlogPost类的典型用法代码示例。如果您正苦于以下问题:C# BlogPost类的具体用法?C# BlogPost怎么用?C# BlogPost使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BlogPost类属于OpenLiveWriter.Extensibility.BlogClient命名空间,在下文中一共展示了BlogPost类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PreparePost
protected internal override void PreparePost(BlogPost blogPost, ref bool? publish)
{
foreach (PostTest test in tests)
{
test.PreparePost(blogPost, ref publish);
}
}
示例2: GetPost
public override BlogPost GetPost(string blogId, string postId)
{
// query for post
XmlNode postResult = CallMethod("blogger.getPost",
new XmlRpcString(APP_KEY),
new XmlRpcString(postId),
new XmlRpcString(Username),
new XmlRpcString(Password, true));
// parse results
try
{
// get the post struct
XmlNode postNode = postResult.SelectSingleNode("struct");
// create a post to return
BlogPost blogPost = new BlogPost();
// extract content
ExtractStandardPostFields(postNode, blogPost);
// return the post
return blogPost;
}
catch (Exception ex)
{
string response = postResult != null ? postResult.OuterXml : "(empty response)";
Trace.Fail("Exception occurred while parsing blogger.getPost response: " + response + "\r\n" + ex.ToString());
throw new BlogClientInvalidServerResponseException("blogger.getPost", ex.Message, response);
}
}
示例3: PreparePost
protected internal override void PreparePost(BlogPost blogPost, ref bool? publish)
{
guid1 = BlogUtil.ShortGuid;
guid2 = BlogUtil.ShortGuid;
blogPost.Title = guid1 + TEST_STRING + guid2;
blogPost.Contents = "foo";
}
示例4: CreateBlogPost
private void CreateBlogPost(string blogId, string postId, string title)
{
BlogPost post = new BlogPost();
if (postId != null)
post.Id = postId;
post.Title = title;
BlogPostEditingContext ctx = new BlogPostEditingContext(blogId, post);
PostEditorFile file = PostEditorFile.CreateNew(tempDir);
file.SaveBlogPost(ctx);
}
示例5: BlogPostEditingContext
public BlogPostEditingContext(string destinationBlogId, BlogPost blogPost, PostEditorFile localFile, PostEditorFile autoSaveLocalFile, string serverSupportingFileDirectory, BlogPostSupportingFileStorage supportingFileStorage, BlogPostImageDataList imageDataList, BlogPostExtensionDataList extensionDataList, ISupportingFileService supportingFileService)
: this(destinationBlogId, blogPost, localFile)
{
_serverSupportingFileDirectory = serverSupportingFileDirectory;
_supportingFileStorage = supportingFileStorage;
_imageDataList = imageDataList;
_extensionDataList = extensionDataList;
_fileService = supportingFileService;
_autoSaveLocalFile = autoSaveLocalFile;
}
示例6: NewPost
public string NewPost(string title, string body, DateTime? dateTime)
{
BlogPost post = new BlogPost();
post.Title = title;
post.Contents = body;
if (dateTime != null)
post.DatePublishedOverride = dateTime.Value;
string eTag;
XmlDocument remotePost;
return client.NewPost(blog.BlogId, post, null, true, out eTag, out remotePost);
}
示例7: DoTest
public override void DoTest(BlogRunner.Core.Config.Blog blog, OpenLiveWriter.Extensibility.BlogClient.IBlogClient blogClient, ITestResults results)
{
BlogPost post = new BlogPost();
post.Contents = "foo";
post.Title = "";
string etag;
XmlDocument remotePost;
try
{
string newPostId = blogClient.NewPost(blog.BlogId, post, null, true, out etag, out remotePost);
results.AddResult("supportsEmptyTitles", YES);
if (CleanUpPosts)
blogClient.DeletePost(blog.BlogId, newPostId, true);
}
catch
{
results.AddResult("supportsEmptyTitles", NO);
}
}
示例8: EditPost
public bool EditPost(string blogId, BlogPost post, INewCategoryContext newCategoryContext, bool publish, out string etag, out XmlDocument remotePost)
{
etag = null;
remotePost = null;
return EditPost(blogId, post, newCategoryContext, publish);
}
示例9: SetPostTitleFromXmlValue
/// <summary>
/// Overridable hook to allow custom handling of setting the post title (in plain text form).
/// This method is called when reading the post title out of an XML-RPC response. Most providers
/// represent the post title value as HTML, so the default implementation here unescapes the encoded HTML
/// back into plain text.
/// </summary>
/// <param name="post"></param>
/// <param name="blogPostTitle"></param>
protected void SetPostTitleFromXmlValue(BlogPost post, string blogPostTitle)
{
bool isHtml = (Options.ReturnsHtmlTitlesOnGet != SupportsFeature.Unknown)
? Options.ReturnsHtmlTitlesOnGet == SupportsFeature.Yes
: Options.RequiresHtmlTitles;
if (!isHtml)
post.Title = blogPostTitle;
else
post.Title = HtmlUtils.UnEscapeEntities(blogPostTitle, HtmlUtils.UnEscapeMode.Default);
}
示例10: EditPage
public bool EditPage(string blogId, BlogPost page, bool publish, out string etag, out XmlDocument remotePost)
{
etag = null;
remotePost = null;
return EditPage(blogId, page, publish);
}
示例11: GenerateCategoriesForPost
protected virtual XmlRpcArray GenerateCategoriesForPost(BlogPost post)
{
ArrayList categoryXmlValues = new ArrayList();
foreach (BlogPostCategory category in post.Categories)
categoryXmlValues.Add(new XmlRpcString(category.Name));
// if we support adding categories then add them too
if (Options.SupportsNewCategories)
foreach (BlogPostCategory category in post.NewCategories)
categoryXmlValues.Add(new XmlRpcString(category.Name));
return new XmlRpcArray((XmlRpcValue[])categoryXmlValues.ToArray(typeof(XmlRpcValue)));
}
示例12: GeneratePostStruct
protected virtual XmlRpcStruct GeneratePostStruct(string blogId, BlogPost post, bool publish)
{
ArrayList members = new ArrayList();
// title
members.Add(new XmlRpcMember("title", new XmlRpcString(GetPostTitleForXmlValue(post))));
// set the contents
if (Options.SupportsExtendedEntries && !post.IsPage)
{
//set the main and extended contents as separate fields
members.Add(new XmlRpcMember("description", new XmlRpcString(post.MainContents)));
members.Add(new XmlRpcMember("mt_text_more", new XmlRpcString(post.ExtendedContents)));
}
else
{
//merge the main and extended contents into a single field
string contents = post.MainContents;
if (post.ExtendedContents != null)
contents += post.ExtendedContents;
members.Add(new XmlRpcMember("description", new XmlRpcString(contents)));
}
// allow comments field
if (Options.SupportsCommentPolicy)
{
if (post.CommentPolicy != BlogCommentPolicy.Unspecified)
{
int policy = -1;
if (Options.CommentPolicyAsBoolean)
{
policy = post.CommentPolicy == BlogCommentPolicy.Open ? 1 : Options.AllowPolicyFalseValue;
}
else
{
switch (post.CommentPolicy)
{
case BlogCommentPolicy.None:
policy = 0;
break;
case BlogCommentPolicy.Open:
policy = 1;
break;
case BlogCommentPolicy.Closed:
policy = 2;
break;
default:
Trace.Fail("Unexpected blog comment policy: " + post.CommentPolicy.ToString());
break;
}
}
if (policy != -1)
members.Add(new XmlRpcMember("mt_allow_comments", new XmlRpcInt(policy)));
}
}
// trackback policy field
if (Options.SupportsPingPolicy)
{
if (post.TrackbackPolicy != BlogTrackbackPolicy.Unspecified)
{
members.Add(new XmlRpcMember("mt_allow_pings",
new XmlRpcInt((post.TrackbackPolicy == BlogTrackbackPolicy.Allow) ? 1 : Options.AllowPolicyFalseValue)));
}
}
// keywords field
if (Options.SupportsKeywords)
{
members.Add(new XmlRpcMember("mt_keywords", new XmlRpcString(post.Keywords)));
}
// slug field
if (Options.SupportsSlug)
{
members.Add(new XmlRpcMember("wp_slug", new XmlRpcString(post.Slug)));
members.Add(new XmlRpcMember("mt_basename", new XmlRpcString(post.Slug)));
}
// password field
if (Options.SupportsPassword)
{
members.Add(new XmlRpcMember("wp_password", new XmlRpcString(post.Password)));
}
// author field
if (Options.SupportsAuthor)
{
if (!post.Author.IsEmpty)
{
members.Add(new XmlRpcMember("wp_author_id", new XmlRpcString(post.Author.Id)));
}
}
// page specific fields
if (post.IsPage)
{
if (Options.SupportsPageParent)
//.........这里部分代码省略.........
示例13: MovableTypeEditPost
private bool MovableTypeEditPost(string blogId, BlogPost post, bool publish)
{
// add the categories to the post
MovableTypeSetPostCategories(post.Id, post.Categories);
// call the base to do the rest of the edit
return MetaweblogEditPost(blogId, post, publish);
}
示例14: EditPage
public bool EditPage(string blogId, BlogPost page, bool publish, out string etag, out XmlDocument remotePost)
{
// The remote post is only meant to be used for blogs that use the Atom protocol.
remotePost = null;
if (!publish && !Options.SupportsPostAsDraft)
{
Trace.Fail("Post to draft not supported on this provider");
throw new BlogClientPostAsDraftUnsupportedException();
}
var bloggerPage = ConvertToGoogleBloggerPage(page);
var updatePostRequest = GetService().Pages.Update(bloggerPage, blogId, page.Id);
updatePostRequest.Publish = publish;
var updatedPage = updatePostRequest.Execute();
etag = updatedPage.ETag;
return true;
}
示例15: NewPost
public string NewPost(string blogId, BlogPost post, INewCategoryContext newCategoryContext, bool publish, out string etag, out XmlDocument remotePost)
{
// The remote post is only meant to be used for blogs that use the Atom protocol.
remotePost = null;
if (!publish && !Options.SupportsPostAsDraft)
{
Trace.Fail("Post to draft not supported on this provider");
throw new BlogClientPostAsDraftUnsupportedException();
}
var bloggerPost = ConvertToGoogleBloggerPost(post);
var newPostRequest = GetService().Posts.Insert(bloggerPost, blogId);
newPostRequest.IsDraft = !publish;
var newPost = newPostRequest.Execute();
etag = newPost.ETag;
return newPost.Id;
}