다음을 통해 공유


CodeFunction2.Parameters 속성

이 항목에 대한 매개 변수 컬렉션을 가져옵니다.

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

구문

‘선언
ReadOnly Property Parameters As CodeElements
CodeElements Parameters { get; }
property CodeElements^ Parameters {
    CodeElements^ get ();
}
abstract Parameters : CodeElements with get
function get Parameters () : CodeElements

속성 값

형식: CodeElements
CodeElements 컬렉션입니다.

설명

참고

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

예제

Sub ParametersExample(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)

        ' Display the function's parameters.
        Dim params As String
        Dim param As CodeParameter
        For Each param In fun.Parameters
            Dim start As TextPoint = param.GetStartPoint()
            Dim finish As TextPoint = param.GetEndPoint()
            params &= start.CreateEditPoint.GetText(finish) & vbCrLf
        Next

        MsgBox(fun.Name & " has the following parameters:" & _
            vbCrLf & vbCrLf & params)
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try

End Sub
public void ParametersExample(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);

        // Display the function's parameters.
        string parms = "";
        foreach (CodeParameter param in fun.Parameters)
        {
            TextPoint start = 
                param.GetStartPoint(vsCMPart.vsCMPartWhole);
            TextPoint finish = 
                param.GetEndPoint(vsCMPart.vsCMPartWhole);
            parms += start.CreateEditPoint().GetText(finish) + 
                Environment.NewLine;
        }

        MessageBox.Show(fun.Name + " has the following parameters:" + 
            Environment.NewLine + Environment.NewLine + parms);
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

.NET Framework 보안

참고 항목

참조

CodeFunction2 인터페이스

EnvDTE80 네임스페이스

기타 리소스

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

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

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