다음을 통해 공유


CodeFunction2.IsShared 속성

항목이 정적으로 정의되는지 여부, 즉 해당 항목이 이 개체 유형의 모든 인스턴스에 공통적으로 적용되는지 아니면 이 개체에만 적용되는지 여부를 가져오거나 설정합니다.

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

구문

‘선언
Property IsShared As Boolean
bool IsShared { get; set; }
property bool IsShared {
    bool get ();
    void set (bool value);
}
abstract IsShared : bool with get, set
function get IsShared () : boolean 
function set IsShared (value : boolean)

속성 값

형식: Boolean
메서드가 공유되면 true이고, 그렇지 않으면 false인 부울 값입니다.

설명

IsShared 반환 하거나 메서드는 클래스와 함께 또는 클래스의 인스턴스와 연결 여부를 설정 합니다. 이때가 로설정하면 언어 종속적 오류를 생성할 수 있습니다. 하지만 IsShared 결과 코드 변경이 성공적으로 컴파일됩니다 의미 하지 않습니다 성공적으로 반환 합니다.

참고

특정 종류의 편집을 수행한 후에는 클래스, 구조체, 함수, 특성, 대리자 등의 코드 모델 요소 값이 명확하지 않을 수 있습니다. 따라서 해당 값이 항상 동일하다고 신뢰할 수 없습니다.자세한 내용은 코드 모델 요소 값에서 변경할 수 있는 섹션을 참조 하십시오. 코드 모델을 사용하여 코드 검색(Visual Basic)합니다.

예제

Sub IsSharedExample(ByVal dte As DTE2)

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

        If fun.IsShared Then
            MsgBox(fun.Name & " is an instance method.")
        Else
            MsgBox(fun.Name & " is not an instance method.")
        End If
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try

End Sub
public void IsSharedExample(DTE2 dte)
{
    // Before running this example, open a code document from a project
    // and place the insertion point inside a function.
    try
    {
        // Retrieve the CodeFunction at the insertion point.
        TextSelection sel = 
            (TextSelection)dte.ActiveDocument.Selection;
        CodeFunction fun = 
            (CodeFunction)sel.ActivePoint.get_CodeElement(
            vsCMElement.vsCMElementFunction);

        if (fun.IsShared)
            MessageBox.Show(fun.Name + " is an instance method.");
        else
            MessageBox.Show(fun.Name + " is not an instance method.");
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

.NET Framework 보안

참고 항목

참조

CodeFunction2 인터페이스

EnvDTE80 네임스페이스

기타 리소스

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

코드 모델을 사용하여 코드 검색(Visual Basic)

코드 모델을 사용하여 코드 검색(Visual C#)