UndoContext.Close 方法
結束復原作業。
命名空間: EnvDTE
組件: EnvDTE (在 EnvDTE.dll 中)
語法
'宣告
Sub Close
void Close()
void Close()
abstract Close : unit -> unit
function Close()
備註
如果 UndoContext 物件有擱置的參考,則 Close 會中止作業並發出錯誤。 如果 UndoContext 物件尚未開啟便呼叫 Close,會發生錯誤。
範例
Sub RemoveNewLines()
' Before running, select text in an open document.
Dim txtSel As TextSelection
Dim strTS As String, boolWasOpen As Boolean
txtSel = DTE.ActiveDocument.Selection
strTS = txtSel.Text
' Check to see if UndoContext object is already open.
If DTE.UndoContext.IsOpen = True Then
boolWasOpen = True
Else
' Open the UndoContext object to track changes.
DTE.UndoContext.Open("RemoveNewLines", False)
End If
' Perform search for newline characters and remove them.
If strTS <> "" Then
txtSel.Delete()
strTS = Replace(strTS, vbNewLine, "", Compare:=vbTextCompare)
txtSel.Insert(strTS)
End If
' If UndoContext was already open, don't close it.
If boolWasOpen = False Then
' Close the UndoContext object to commit the changes.
DTE.UndoContext.Close()
End If
End Sub
.NET Framework 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。