当前位置: 首页>>代码示例>>C#>>正文


C# UmbracoHelper.NiceUrlWithDomain方法代码示例

本文整理汇总了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;
        }
开发者ID:simonech,项目名称:Articulate,代码行数:69,代码来源:DisqusXmlExporter.cs

示例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);
		}
开发者ID:elrute,项目名称:Triphulcas,代码行数:10,代码来源:PublishedContentExtensions.cs


注:本文中的UmbracoHelper.NiceUrlWithDomain方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。