本文整理汇总了C#中UmbracoHelper.NiceUrlWithDomain方法的典型用法代码示例。如果您正苦于以下问题:C# UmbracoHelper.NiceUrlWithDomain方法的具体用法?C# UmbracoHelper.NiceUrlWithDomain怎么用?C# UmbracoHelper.NiceUrlWithDomain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UmbracoHelper
的用法示例。
在下文中一共展示了UmbracoHelper.NiceUrlWithDomain方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Export
public XDocument Export(IEnumerable<IContent> posts, BlogMLDocument document)
{
var nsContent = XNamespace.Get("http://purl.org/rss/1.0/modules/content/");
var nsDsq = XNamespace.Get("http://www.disqus.com/");
var nsDc = XNamespace.Get("http://purl.org/dc/elements/1.1/");
var nsWp = XNamespace.Get("http://wordpress.org/export/1.0/");
var xChannel = new XElement("channel");
var xDoc = new XDocument(
new XElement("rss",
new XAttribute("version", "2.0"),
new XAttribute(XNamespace.Xmlns + "content", nsContent),
new XAttribute(XNamespace.Xmlns + "dsq", nsDsq),
new XAttribute(XNamespace.Xmlns + "dc", nsDc),
new XAttribute(XNamespace.Xmlns + "wp", nsWp),
xChannel));
var umbHelper = new UmbracoHelper(UmbracoContext.Current);
var markDown = new MarkdownDeep.Markdown();
foreach (var post in posts)
{
var blogMlPost = document.Posts.FirstOrDefault(x => x.Title.Content == post.Name);
//TODO: Add logging here if we cant find it
if (blogMlPost == null) continue;
//no comments to import
if (blogMlPost.Comments.Any() == false) continue;
var body = post.GetValue<string>("richText");
if (body.IsNullOrWhiteSpace())
{
body = markDown.Transform(post.GetValue<string>("markdown"));
}
var xItem = new XElement("item",
new XElement("title", post.Name),
new XElement("link", umbHelper.NiceUrlWithDomain(post.Id)),
new XElement(nsContent + "encoded", new XCData(body)),
new XElement(nsDsq + "thread_identifier", post.Key.ToString()),
new XElement(nsWp + "post_date_gmt", post.GetValue<DateTime>("publishedDate").ToUniversalTime().ToIsoString()),
new XElement(nsWp + "comment_status", "open"));
foreach (var comment in blogMlPost.Comments)
{
string commentText = comment.Content.Content;
if (comment.Content.ContentType == BlogMLContentType.Base64)
commentText = Encoding.UTF8.GetString(Convert.FromBase64String(comment.Content.Content));
var xComment = new XElement(nsWp + "comment",
new XElement(nsWp + "comment_id", comment.Id),
new XElement(nsWp + "comment_author", comment.UserName),
new XElement(nsWp + "comment_author_email", comment.UserEmailAddress),
new XElement(nsWp + "comment_author_url", comment.UserUrl == null ? string.Empty : comment.UserUrl.ToString()),
new XElement(nsWp + "comment_date_gmt", comment.CreatedOn.ToUniversalTime().ToIsoString()),
new XElement(nsWp + "comment_content", commentText),
new XElement(nsWp + "comment_approved", comment.ApprovalStatus == BlogMLApprovalStatus.Approved ? 1 : 0));
xItem.Add(xComment);
}
xChannel.Add(xItem);
}
return xDoc;
}
示例2: NiceUrlWithDomain
/// <summary>
/// Gets the NiceUrlWithDomain for the content item
/// </summary>
/// <param name="doc"></param>
/// <returns></returns>
public static string NiceUrlWithDomain(this IPublishedContent doc)
{
var umbHelper = new UmbracoHelper(UmbracoContext.Current);
return umbHelper.NiceUrlWithDomain(doc.Id);
}