管理多个版本视为单个操作的事件,优化的文本视图。
此 API 不兼容 CLS。 兼容 CLS 的替代 API 为 [None]。
继承层次结构
System.Object
Microsoft.VisualStudio.Package.CompoundViewAction
命名空间: Microsoft.VisualStudio.Package
程序集: Microsoft.VisualStudio.Package.LanguageService(在 Microsoft.VisualStudio.Package.LanguageService.dll 中)
Microsoft.VisualStudio.Package.LanguageService.11.0(在 Microsoft.VisualStudio.Package.LanguageService.11.0.dll 中)
Microsoft.VisualStudio.Package.LanguageService.9.0(在 Microsoft.VisualStudio.Package.LanguageService.9.0.dll 中)
Microsoft.VisualStudio.Package.LanguageService.10.0(在 Microsoft.VisualStudio.Package.LanguageService.10.0.dll 中)
语法
声明
<CLSCompliantAttribute(False)> _
Public Class CompoundViewAction _
Implements IDisposable
[CLSCompliantAttribute(false)]
public class CompoundViewAction : IDisposable
CompoundViewAction 类型公开以下成员。
构造函数
名称 | 说明 | |
---|---|---|
![]() |
CompoundViewAction | 初始化 CompoundViewAction 类的新实例。 |
页首
方法
名称 | 说明 | |
---|---|---|
![]() |
Abort() | 停止当前多个事件,引发所有编辑器。 (继承自 CompoundActionBase。) |
![]() |
Abort() | |
![]() |
Close() | 关闭该复合事件并进行编辑到源文件。 (继承自 CompoundActionBase。) |
![]() |
Close() | |
![]() |
Dispose() | ,在销毁之前,释放的所有资源 CompoundAction 对象。 (继承自 CompoundActionBase。) |
![]() |
Dispose() | |
![]() |
Equals | 确定指定的对象是否等于当前对象。 (继承自 Object。) |
![]() |
Finalize | 允许对象在“垃圾回收”回收之前尝试释放资源并执行其他清理操作。 (继承自 Object。) |
![]() |
FlushEditActions() | 对于所有挂起的编辑从当前多个事件。 (继承自 CompoundActionBase。) |
![]() |
FlushEditActions() | |
![]() |
GetHashCode | 用作特定类型的哈希函数。 (继承自 Object。) |
![]() |
GetType | 获取当前实例的 Type。 (继承自 Object。) |
![]() |
MemberwiseClone | 创建当前 Object 的浅表副本。 (继承自 Object。) |
![]() |
ToString | 返回表示当前对象的字符串。 (继承自 Object。) |
页首
字段
名称 | 说明 | |
---|---|---|
![]() |
action | CompoundAction 事件的接口。 (继承自 CompoundActionBase。) |
![]() |
opened | 指定是否打开了一个复合事件。 (继承自 CompoundActionBase。) |
页首
备注
此类用于简化包装集合编辑器可以向单个操作。这是通过调用从指定的 IVsTextView 对象中获取的 IVsCompoundAction 接口的 OpenCompoundAction 方法实现。当此类处理时, IVsCompoundAction 接口是关闭的,并提交以单个操作进行的。 IVsTextLines 对象所有编辑器事件。
对实现者的说明
,在此类处理时,此类包含所必需的所有内容打开生成的复合事件 IVsTextView 对象和结束该事件。
对调用者的说明
请实例化 IVsTextView 对象的一 CompoundViewAction 对象,您需要包装一个或多个编辑器在一个操作可以取消操作时。然后执行编辑操作作为普通。在新 CompoundViewAction 对象已处理时,编辑操作存储为单个操作。
使用此类优先于 CompoundAction 类,此类使文本视图优化所做的任何编辑。
![]() |
---|
因为 CompoundViewAction 类直接与视图时, colorizer 不需要由类挂起。 |
示例
此示例演示如何使用 CompoundViewAction 类。此示例单词插入列出当前位置的源文件。不 CompoundViewAction 对象,这些插入都被视为单独的编辑事件并需要单独取消操作。但是,与 CompoundViewAction 对象,整个列表可以取消与单个撤消。
using Microsoft.VisualStudio.Package
namespace MyLanguagePackage
{
class CMyLanguageService : LanguageService
{
// Insert the list of words, one per line.
void InsertWords(Source src,string[] wordList)
{
if (LastActiveTextView != null)
{
CompoundViewAction action = new CompoundViewAction(LastActiveTextView,
"Update source");
using (action)
{
int currentLine = 0;
int currentCol = 0;
LastActiveTextView.GetCaretPos(out currentLine, out currentCol);
// Insert list in reverse so the words appear in the proper
// order in the sourec file.
for (int i = wordList.Length - 1, i >= 0; i--)
{
string w = wordList[i] + "\n";
src.SetText(currentLine, currentCol, currentLine, currentCol, w);
}
}
}
}
}
}
线程安全
此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。