VSProject2.Project Özellik

Tanım

ProjectVisual Basic veya Visual C# projesiyle ilişkili genel nesneyi alır.

public:
 property EnvDTE::Project ^ Project { EnvDTE::Project ^ get(); };
public:
 property EnvDTE::Project ^ Project { EnvDTE::Project ^ get(); };
[System.Runtime.InteropServices.DispId(4)]
public EnvDTE.Project Project { [System.Runtime.InteropServices.DispId(4)] get; }
[<System.Runtime.InteropServices.DispId(4)>]
[<get: System.Runtime.InteropServices.DispId(4)>]
member this.Project : EnvDTE.Project
Public ReadOnly Property Project As Project

Özellik Değeri

Project

Bir Project nesnesi.

Uygulamalar

Öznitelikler

Örnekler

Bu örneği bir eklenti olarak çalıştırmak için bkz. nasıl yapılır: derleme ve Otomasyon nesne modeli kodu örnekleri çalıştırma. Visual Basic Visual C# Bu örneği çalıştırmadan önce bir veya projesi açın.

[Visual Basic]

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)  
    VSProjectSavedExample(applicationObject)  
End Sub  
Sub VSProjectSavedExample(ByVal dte As DTE2)  
    Dim aProject As Project  
    Dim aVSProject As VSProject2  
    aProject = applicationObject.Solution.Projects.Item(1)  
    aVSProject = CType(applicationObject.Solution.Projects.Item(1)._  
    Object, VSProject2)  
    IsProjectSaved(aVSProject)  
End Sub  
' Displays whether project has unsaved changes.  
Sub IsProjectSaved(ByVal aVSProject As VSProject2)  
    Dim theProject As EnvDTE.Project  
    theProject = aVSProject.Project  
    If (theProject.Saved) Then  
        MsgBox(theProject.Name & " is saved.")  
    Else  
        MsgBox(theProject.Name & " is not saved.")  
    End If  
End Sub  

Þ

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;  
    VSProjectSavedExample((DTE2)applicationObject);  
}  

public void VSProjectSavedExample( DTE2 dte )   
{   
    Project aProject = null;   
    VSProject aVSProject = null;   
    aProject = applicationObject.Solution.Projects.Item( 1 );   
    aVSProject = ( ( VSProject )( applicationObject.Solution.Projects.  
Item( 1 ).Object ) );   
    IsProjectSaved( aVSProject );   
}   

//  Displays whether project has unsaved changes.  
public void IsProjectSaved( VSProject aVSProject )   
{   
    EnvDTE.Project theProject = null;   
    theProject = aVSProject.Project;   
    if ( ( theProject.Saved ) )   
    {   
        MessageBox.Show( theProject.Name + " is saved.");   
    }   
    else   
    {   
        MessageBox.Show( theProject.Name + " is not saved.");   
    }   
}  

Açıklamalar

VSProject2Nesnesi bir genel Project nesnenin özelliğidir. ProjectÖzelliği, genel genişletilebilirlik nesnesine erişim sağlar Project .

Şunlara uygulanır