本文整理汇总了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;
}
}
示例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));
}