本文整理汇总了C#中ITextBuffer.GetSourceBuffersRecursive方法的典型用法代码示例。如果您正苦于以下问题:C# ITextBuffer.GetSourceBuffersRecursive方法的具体用法?C# ITextBuffer.GetSourceBuffersRecursive怎么用?C# ITextBuffer.GetSourceBuffersRecursive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITextBuffer
的用法示例。
在下文中一共展示了ITextBuffer.GetSourceBuffersRecursive方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Save
internal Result Save(ITextBuffer textBuffer)
{
// In order to save the ITextBuffer we need to get a document cookie for it. The only way I'm
// aware of is to use the path moniker which is available for the accompanying ITextDocment
// value.
//
// In many types of files (.cs, .vb, .cpp) there is usually a 1-1 mapping between ITextBuffer
// and the ITextDocument. But in any file type where an IProjectionBuffer is common (.js,
// .aspx, etc ...) this mapping breaks down. To get it back we must visit all of the
// source buffers for a projection and individually save them
var result = Result.Success;
foreach (var sourceBuffer in textBuffer.GetSourceBuffersRecursive())
{
// The inert buffer doesn't need to be saved. It's used as a fake buffer by web applications
// in order to render projected content
if (sourceBuffer.ContentType == _textBufferFactoryService.InertContentType)
{
continue;
}
var sourceResult = SaveCore(sourceBuffer);
if (sourceResult.IsError)
{
result = sourceResult;
}
}
return result;
}
示例2: IsDirty
public virtual bool IsDirty(ITextBuffer textBuffer)
{
// If this is an IProjectionBuffer then we need to dig into the actual ITextBuffer values
// which make it up.
foreach (var sourceTextBuffer in textBuffer.GetSourceBuffersRecursive())
{
// The inert buffer doesn't need to be considered. It's used as a fake buffer by web applications
// in order to render projected content
if (sourceTextBuffer.ContentType == _textBufferFactoryService.InertContentType)
{
continue;
}
ITextDocument document;
if (_textDocumentFactoryService.TryGetTextDocument(sourceTextBuffer, out document) && document.IsDirty)
{
return true;
}
}
return false;
}