Share via


VSProject2.Project (Propiedad)

Obtiene el objeto Project genérico asociado al proyecto de Visual Basic o Visual C#.

Espacio de nombres:  VSLangProj80
Ensamblado:  VSLangProj80 (en VSLangProj80.dll)

Sintaxis

'Declaración
ReadOnly Property Project As Project
Project Project { get; }
property Project^ Project {
    Project^ get ();
}
abstract Project : Project with get
function get Project () : Project

Valor de propiedad

Tipo: Project
Un objeto Project.

Comentarios

El objeto VSProject2 es una propiedad de un objeto Project genérico. La propiedad Project proporciona acceso al objeto Project de extensibilidad general.

Ejemplos

Para ejecutar este ejemplo como complemento, vea Cómo: Compilar y ejecutar los ejemplos de código del modelo de objetos de automatización. Abra un proyecto de Visual Basic o Visual C# antes de ejecutar este ejemplo.

[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

[C#]

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."); 
    } 
}

Seguridad de .NET Framework

Vea también

Referencia

VSProject2 Interfaz

VSLangProj80 (Espacio de nombres)

Project