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


C# Document.ToXDocument方法代码示例

本文整理汇总了C#中umbraco.cms.businesslogic.web.Document.ToXDocument方法的典型用法代码示例。如果您正苦于以下问题:C# Document.ToXDocument方法的具体用法?C# Document.ToXDocument怎么用?C# Document.ToXDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在umbraco.cms.businesslogic.web.Document的用法示例。


在下文中一共展示了Document.ToXDocument方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Document_AfterSave

		private void Document_AfterSave(Document sender, SaveEventArgs e)
        {
            //ensure that only the providers that have unpublishing support enabled     
            //that are also flagged to listen

            //there's a bug in 4.0.x that fires the Document saving event handler for media when media is moved,
            //therefore, we need to try to figure out if this is media or content. Currently one way to do this
            //is by checking the creator ID property as it will be null if it is media. We then need to try to 
            //create the media object, see if it exists, and pass it to the media save event handler... yeah i know, 
            //pretty horrible but has to be done.

            try
            {
                var creator = sender.Creator;
                if (creator != null)
                {
                    //it's def a Document
                    ExamineManager.Instance.ReIndexNode(sender.ToXDocument(false).Root, IndexTypes.Content,
                        ExamineManager.Instance.IndexProviderCollection.OfType<BaseUmbracoIndexer>()
                            .Where(x => x.SupportUnpublishedContent
                                && x.EnableDefaultEventHandler));

                    return; //exit, we've indexed the content
                }
            }
            catch (Exception)
            {
                //if we get this exception, it means it's most likely media, so well do our check next.   
            }

            //this is most likely media, not sure what kind of exception might get thrown in 4.0.x or 4.1 if accessing a null
            //creator, so we catch everything.

            var m = new Media(sender.Id);
            if (!string.IsNullOrEmpty(m.Path))
            {
                //this is a media item, no exception occurred on access to path and it's not empty which means it was found
                Media_AfterSave(m, e);
                return;
            }


        }
开发者ID:Xamarui,项目名称:Examine,代码行数:43,代码来源:UmbracoEventManager.cs

示例2: content_AfterUpdateDocumentCache

 /// <summary>
 /// Only Update indexes for providers that dont SupportUnpublishedContent
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void content_AfterUpdateDocumentCache(Document sender, umbraco.cms.businesslogic.DocumentCacheEventArgs e)
 {
     //ensure that only the providers that have DONT unpublishing support enabled       
     //that are also flagged to listen
     ExamineManager.Instance.ReIndexNode(sender.ToXDocument(true).Root, IndexTypes.Content,
         ExamineManager.Instance.IndexProviderCollection.OfType<BaseUmbracoIndexer>()
             .Where(x => !x.SupportUnpublishedContent
                 && x.EnableDefaultEventHandler));
 }
开发者ID:Xamarui,项目名称:Examine,代码行数:14,代码来源:UmbracoEventManager.cs


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