다음을 통해 공유


CodeProperty.Getter 속성

속성을 반환하기 위한 코드를 정의하는 개체를 가져오거나 설정합니다.

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

구문

‘선언
Property Getter As CodeFunction
    Get
    Set
CodeFunction Getter { get; set; }
property CodeFunction^ Getter {
    CodeFunction^ get ();
    void set (CodeFunction^ value);
}
abstract Getter : CodeFunction with get, set
function get Getter () : CodeFunction
function set Getter (value : CodeFunction)

속성 값

형식: EnvDTE.CodeFunction
CodeFunction 개체입니다.

설명

Getter는 이 속성의 getter에 해당하는 코드 함수가 있는 경우 이 함수를 반환합니다.

참고

Visual Basic 소스 코드의 코드 요소인 경우 이 속성은 읽기 전용입니다.

또한 클래스, 구조체, 함수, 특성, 대리자 등의 코드 모델 요소를 특정한 방식으로 편집한 후에는 요소의 값이 명확하지 않을 수 있습니다. 즉, 요소의 값이 항상 같다고 할 수 없습니다. 자세한 내용은 코드 모델을 사용하여 코드 검색(Visual Basic)의 "코드 모델 요소 값이 변경될 수 있음" 단원을 참조하십시오.

예제

Sub GetterExample(ByVal dte As DTE2)

    ' Before running this example, open a code document from a project
    ' and place the insertion point inside a property definition.
    Try
        ' Retrieve the CodeProperty at the insertion point.
        Dim sel As TextSelection = _
            CType(dte.ActiveDocument.Selection, TextSelection)
        Dim prop As CodeProperty = _
            CType(sel.ActivePoint.CodeElement( _
            vsCMElement.vsCMElementProperty), CodeProperty)

        ' Display the source code for the property getter.
        Dim gttr As CodeFunction = prop.Getter
        Dim start As TextPoint = gttr.GetStartPoint()
        Dim finish As TextPoint = gttr.GetEndPoint()
        Dim src As String = start.CreateEditPoint().GetText(finish)

        MsgBox(prop.Name & "'s getter source code:" & vbCrLf & _
            vbCrLf & src)
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try

End Sub
public void GetterExample(DTE2 dte)
{
    // Before running this example, open a code document from a project
    // and place the insertion point inside a property definition.
    try
    {
        // Retrieve the CodeProperty at the insertion point.
        TextSelection sel = 
            (TextSelection)dte.ActiveDocument.Selection;
        CodeProperty prop = 
            (CodeProperty)sel.ActivePoint.get_CodeElement(
            vsCMElement.vsCMElementProperty);

        // Display the source code for the property getter.
        CodeFunction getter = prop.Getter;
        TextPoint start = getter.GetStartPoint(vsCMPart.vsCMPartWhole);
        TextPoint finish = getter.GetEndPoint(vsCMPart.vsCMPartWhole);
        string src = start.CreateEditPoint().GetText(finish);

        MessageBox.Show(prop.Name + "'s getter source code:\n\n" +
            src);
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

.NET Framework 보안

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

참고 항목

참조

CodeProperty 인터페이스

EnvDTE 네임스페이스

기타 리소스

방법: 자동화 개체 모델 코드의 예제 컴파일 및 실행