다음을 통해 공유


UndoContext.Open 메서드

새로운 실행 취소 동작을 시작합니다.

네임스페이스:  EnvDTE
어셈블리:  EnvDTE(EnvDTE.dll)

구문

‘선언
Sub Open ( _
    Name As String, _
    Strict As Boolean _
)
void Open(
    string Name,
    bool Strict
)
void Open(
    [InAttribute] String^ Name, 
    [InAttribute] bool Strict
)
abstract Open : 
        Name:string * 
        Strict:bool -> unit 
function Open(
    Name : String, 
    Strict : boolean
)

매개 변수

  • Name
    형식: System.String
    필수적 요소로서,실행 취소 컨텍스트가 제공될 대상 프로시저의 이름을 나타냅니다.
  • Strict
    형식: System.Boolean
    선택적 요소로서,실행 취소 스택 링크가 strict인지 여부를 나타냅니다.기본값은 False입니다.

설명

Open 메서드를 수행할 때 UndoContext 개체가 이미 열려 있으면 오류가 발생합니다.

실행 취소 스택이 엄격히 연결된 경우 연결된 모든 실행 취소 형제 스택을 함께 실행 취소해야 하거나 아예 실행 취소하지 않도록 지정합니다. 강하게 연결된 실행 취소 작업은 대개 헤더 파일 및 Visual C++ 파일 같은 여러 파일에 걸쳐 동시 텍스트 변경에 일반적으로 필요합니다. 이것은 Visual Studio에서 사용되는 모델입니다. 스택 연결에 대한 자세한 내용은 OpenLinkedUndo 메서드를 참조하십시오.

예제

Sub OpenExample()
   ' 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 보안

  • 직접 실행 호출자의 경우 완전히 신뢰합니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분 신뢰 코드에서 라이브러리 사용을 참조하십시오.

참고 항목

참조

UndoContext 인터페이스

EnvDTE 네임스페이스