Project.Globals 속성

솔루션 파일(.sln), 프로젝트 파일 또는 사용자의 프로필 데이터에 저장되는 추가 기능 값이 포함된 Globals 개체를 가져옵니다.

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

구문

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

속성 값

형식: EnvDTE.Globals
Globals 개체

설명

솔루션, 프로젝트 파일을이 로드 된 추가 기능을 사용할 수 있습니다.

Solutionglobals 추가 기능을 반드시 연관 되지 않습니다. 이러한 매크로 또는 기타 자동화 클라이언트를 연결할 수도 있습니다.

참고

VariableValue이름 문자열 공간, 콜론 (:), 또는 period(.) 문자를 포함할 수 없습니다.이러한 문자는 이름이 있으면 오류가 발생, "값 예상된 범위 내에 포함 되지 않습니다."

예제

Public Sub CodeExample(ByVal dte As DTE2) 
    Try
        ' Open a project before running this sample.
        Dim prj As Project = dte.Solution.Projects.Item(1)
        Dim prjs As Projects
        Dim msg2 As String = "Global Variables:"
        Dim msg As String
        msg = "FileName: " + prj.FileName
        msg += vbCrLf + "FullName: " + prj.FullName
        msg += vbCrLf + "Project-level access to " + prj.CodeModel.CodeElements.Count.ToString() + " CodeElements through the CodeModel"
        prjs = prj.Collection
        msg += vbCrLf + "There are " + prjs.Count.ToString() + " projects in the same collection."
        msg += vbCrLf + "Application containing this project: " + prj.DTE.Name
        If prj.Saved Then
            msg += vbCrLf + "This project has not been modified since the last save."
        Else
            msg += vbCrLf + "This project has been modified since the last save."       
        End If
        msg +=  vbCrLf + "Properties:"
        Dim prop As [Property]
        For Each prop In  prj.Properties
            msg += vbCrLf + "  " + prop.Name
        Next prop
        Dim s As String
        For Each s In  CType(prj.Globals.VariableNames, Array)
            msg2 += vbCrLf + "  " + s
        Next s
        
        MessageBox.Show(msg, "Project Name: " + prj.Name)
        MessageBox.Show(msg2)
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try
End Sub
public void CodeExample(DTE2 dte)
{  
    try
    {   // Open a project before running this sample.
        Project prj = dte.Solution.Projects.Item(1);
        Projects prjs;
        string msg, msg2 = "Global Variables:";
        msg = "FileName: " + prj.FileName;
        msg += "\nFullName: " + prj.FullName;
        msg += "\nProject-level access to " + prj.CodeModel.CodeElements.Count.ToString() +
            " CodeElements through the CodeModel";
        prjs = prj.Collection;
        msg += "\nThere are " + prjs.Count.ToString() + " projects in the same collection.";
        msg += "\nApplication containing this project: " + prj.DTE.Name;
        if (prj.Saved)
            msg += "\nThis project hasn't been modified since the last save.";
        else
            msg += "\nThis project has been modified since the last save.";
        msg += "\nProperties: ";
        foreach (Property prop in prj.Properties)
        {
            msg += "\n  " + prop.Name;
        }
        foreach (String s in (Array)prj.Globals.VariableNames)
        {
            msg2 += "\n  " + s;
        }

        MessageBox.Show(msg, "Project Name: " + prj.Name);
        MessageBox.Show(msg2);
    }
    catch(Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

.NET Framework 보안

참고 항목

참조

Project 인터페이스

EnvDTE 네임스페이스

기타 리소스

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