다음을 통해 공유


Reference3.ContainingProject 속성

참조를 포함하는 Project를 가져옵니다.

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

구문

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

속성 값

형식: EnvDTE.Project
참조를 포함하는 Project 개체입니다.

설명

이 속성을 사용하여 참조가 포함된 Project 개체를 검색합니다.

예제

이 예제에서는 모든 참조가 들어 있는 프로젝트와 열린 Visual Basic 또는 Visual C# 프로젝트에 각 참조가 별개로 들어 있는 프로젝트를 표시합니다.이 예제를 추가 기능으로 실행하려면 방법: 자동화 개체 모델 코드의 예제 컴파일 및 실행을 참조하십시오.

Imports VSLangProj
Imports VSLangProj2
Imports VSLangProj80
Public Sub OnConnection(ByVal application As Object, _
 ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, _
 ByRef custom As Array) Implements IDTExtensibility2.OnConnection
    applicationObject = CType(application, DTE2)
    addInInstance = CType(addInInst, AddIn)
    TestGetProjectName(applicationObject)
End Sub
Sub TestGetProjectName(ByVal dte As DTE2)
    ' First project is a Visual Basic or C# project.
    Dim theVSProject As VSProject2 = _
    CType(applicationObject.Solution.Projects.Item(1)._
    Object, VSProject2)
    Dim refs As References = theVSProject.References
    MsgBox("The containing project for all references is : " _
    & GetProjectName(refs))
    Dim aRef As Reference3
    Dim refStr As String
    refStr = ""
    For Each aRef In theVSProject.References
        refStr &= (aRef.Name & "'s containing project is: " _
        & aRef.ContainingProject.Name & vbCr)
    Next
    MsgBox("The containing project for each reference in the project:" _
    & vbCr & vbCr & refStr & vbCr)
End Sub
Private Function GetProjectName(ByVal refs As References) _
    As String
    Return refs.ContainingProject.Name
End Function
using System.Windows.Forms;
using VSLangProj;
using VSLangProj2;
using VSLangProj80;
public void OnConnection(object application, 
ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
    applicationObject = (DTE2)application;
    addInInstance = (AddIn)addInInst;
    TestGetProjectName(((DTE2)applicationObject));
}
public void TestGetProjectName(DTE2 dte)
{
    // First project is a Visual Basic or C# project.
    VSProject2 theVSProject = 
((VSProject2)(applicationObject.Solution.Projects.Item(1).Object));
    References refs = theVSProject.References;
    MessageBox.Show("The containing project for all references is : " 
+ GetProjectName(refs));
    Reference aRef = null;
    string refStr = null;
    refStr = "";
    foreach (VSLangProj80.Reference3 temp in theVSProject.References)
    {
        aRef = temp;
        refStr += (aRef.Name + "'s containing project is: " 
+ aRef.ContainingProject.Name + "\n");
    }
    MessageBox.Show("The containing project for each reference in 
the project:" + "\n" + "\n" + refStr + "\n");
}

private string GetProjectName(References refs)
{
    return refs.ContainingProject.Name;
}

.NET Framework 보안

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

참고 항목

참조

Reference3 인터페이스

ContainingProject 오버로드

VSLangProj80 네임스페이스