本文整理汇总了C#中ITextBuffer.GetContributingBuffers方法的典型用法代码示例。如果您正苦于以下问题:C# ITextBuffer.GetContributingBuffers方法的具体用法?C# ITextBuffer.GetContributingBuffers怎么用?C# ITextBuffer.GetContributingBuffers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITextBuffer
的用法示例。
在下文中一共展示了ITextBuffer.GetContributingBuffers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetVersion
public Version GetVersion(ITextBuffer textBuffer)
{
Version version = null;
if (textBuffer != null)
{
bool fromCache = false;
foreach (var buffer in textBuffer.GetContributingBuffers())
{
if (buffer.Properties.TryGetProperty(RazorSupportedRuntimeVersion2, out version))
{
fromCache = true;
break;
}
}
if (!fromCache)
{
var getExplicitWebPagesVersionMethod = _getExplicitWebPagesVersionMethod.Value;
if (getExplicitWebPagesVersionMethod != null)
{
var fileName = textBuffer.GetFileName();
var projectData = Microsoft.VisualStudio.Html.Package.Project.ProjectData.FromFileNameAndPath(fileName);
if (projectData != null)
{
var absolutePath = VsWebUrl.CreateAppUrl(projectData.Hierarchy, projectData.ItemID).AbsolutePath;
try
{
version = (Version)getExplicitWebPagesVersionMethod.Invoke(null, new object[] { absolutePath });
}
catch
{
}
}
}
textBuffer.Properties[RazorSupportedRuntimeVersion2] = version;
}
if (version != null)
{
if (_inner != null)
{
var innerType = _inner.GetType();
var setCachedVersionMethod = _setCachedVersionMethodCache.GetOrAdd(innerType,
type => type.GetMethod("SetCachedVersion", BindingFlags.Instance | BindingFlags.NonPublic, null, new[] { typeof(ITextBuffer), typeof(Version) }, null));
if (setCachedVersionMethod != null)
{
try
{
setCachedVersionMethod.Invoke(_inner, new object[] { textBuffer, version });
}
catch (TargetInvocationException)
{
}
}
}
return version;
}
}
if (_inner != null)
version = _inner.GetVersion(textBuffer);
return version;
}