Globals.VariableValue 속성

지정한 이름의 변수를 반환하거나 설정합니다.

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

구문

‘선언
Default Property VariableValue ( _
    VariableName As String _
) As Object
Object this[
    string VariableName
] { get; set; }
property Object^ default[String^ VariableName] {
    Object^ get (String^ VariableName);
    void set (String^ VariableName, Object^ value);
}
abstract VariableValue : 
        VariableName:string -> Object with get, set
JScript에서는 인덱싱된 속성을 지원하지 않습니다.

매개 변수

  • VariableName
    형식: String

    필수입니다. 검색할 변수의 이름을 나타내는 문자열입니다.

속성 값

형식: Object
변수를 나타내는 개체입니다.

설명

존재하지 않는 변수를 검색하려고 하면 빈 값을 사용하는 변수가 만들어지고 존재하지 않는 변수를 설정하려고 하면 지정된 값을 사용하는 변수가 만들어집니다.

참고

VariableValue 이름 문자열에는 공백, 콜론(:) 또는 마침표(.) 문자를 사용할 수 없습니다.이름에 이러한 문자가 들어 있으면 "값이 예상 범위를 벗어났습니다."라는 오류 메시지가 나타납니다.

예제

Sub OnAddinLoaded(ByVal dte As DTE)
    ' Count the number of times an add-in is loaded
    ' and store the value in the solution.
    Dim globals As Globals
    globals = dte.Solution.Globals
    If globals.VariableExists("AddinLoadCounter") Then
        ' The counter has already been set, so increment it.
        Dim int32 As System.Int32
        int32 = System.Int32.Parse(CStr(globals("AddinLoadCounter")))
        int32 += 1
        globals("AddinLoadCounter") = int32.ToString()
    Else
        ' Counter has never been set, so create and initialize it.
        globals("AddinLoadCounter") = 1.ToString()
        globals.VariablePersists("AddinLoadCounter") = True
    End If
    MsgBox("This add-in has been loaded: " & _
    globals.VariableValue("AddinLoadCounter") & " times.")
End Sub
void OnAddinLoaded(_DTE applicationObject)
{
    // Count the number of times an add-in is loaded
    // and store the value in the solution.
    Globals globals;
    globals = applicationObject.Solution.Globals;
    if(globals.get_VariableExists("AddinLoadCounter"))
    {
        // The counter has already been set, so increment it.
        System.Int32 int32;
        int32 = System.Int32.Parse((string)
        globals["AddinLoadCounter"]);
        int32++;
        globals["AddinLoadCounter"] = int32.ToString();
    }
    else
    {
        // Counter has never been set, so create and initialize it.
        globals["AddinLoadCounter"] = 1.ToString();
        globals.set_VariablePersists("AddinLoadCounter", true);
    }
    System.Windows.Forms.MessageBox.Show("This add-in has been loaded: 
    " + globals.VariableValue["AddinLoadCounter"] + " times.");
}

.NET Framework 보안

참고 항목

참조

Globals 인터페이스

EnvDTE 네임스페이스

기타 리소스

프로젝트 및 솔루션에 정보 유지

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