Właściwość CodeClass.Parent —

Zwraca obiekt nadrzędny natychmiastowe z CodeClass obiektu.

Przestrzeń nazw:  EnvDTE
Zestaw:  EnvDTE (w EnvDTE.dll)

Składnia

'Deklaracja
ReadOnly Property Parent As Object
Object Parent { get; }
property Object^ Parent {
    Object^ get ();
}
abstract Parent : Object with get
function get Parent () : Object

Wartość właściwości

Typ: Object
Obiektem nadrzędnym natychmiastowego CodeClass obiektu.

Uwagi

Parent Właściwość zwraca bezpośrednio nadrzędnego w stosunku do CodeClass obiektu.Aby uzyskać zawierające kolekcji, należy użyć Collection właściwości.

[!UWAGA]

Po dokonaniu niektórych rodzajów modyfikacji, co oznacza, że ich wartości nie może polegać na zawsze pozostawać taki sam może być nie deterministyczny wartości elementów modelu kodu, takich jak klasy, strukturach, funkcje, atrybuty, delegatów i tak dalej.Aby uzyskać więcej informacji, zobacz sekcję wartości elementu modelu kod można zmienić w Odnajdowanie kodu za pomocą modelu kodu (Visual Basic).

Przykłady

Public Sub CodeClassExample(ByVal dte As DTE2) 
    ' Before running this example, open a code document from a
    ' project and place the insertion point inside a class definition.
    Try
        Dim objTextSel As TextSelection
        Dim objCodeCls As CodeClass
        Dim objCodeElem As CodeElement
        objTextSel = CType(dte.ActiveDocument.Selection, TextSelection)
        objCodeCls = CType(objTextSel.ActivePoint.CodeElement(vsCMElement.vsCMElementClass), CodeClass)
        ' Display the fullname of CodeClass object.
        MessageBox.Show(objCodeCls.FullName)
        ' Prove that the parent object of a CodeClass is a CodeElement.
        objCodeElem = CType(objCodeCls.Parent, CodeElement)
        ' Get access privilege for CodeClass.
        MessageBox.Show(objCodeCls.Access.ToString())
        ' Change access privilege for CodeClass objCodeCls.
        ' Note the change in access keyword in your code document.
        objCodeCls.Access = vsCMAccess.vsCMAccessPublic
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try
End Sub
public void CodeClassExample(DTE2 dte)
{ 
   // Before running this example, open a code document from a
   // project and place the insertion point inside a class definition.
   try
   {
      TextSelection objTextSel;
      CodeClass objCodeCls;
      CodeElement objCodeElem;
      objTextSel = (TextSelection)dte.ActiveDocument.Selection;
      objCodeCls = (CodeClass)objTextSel.ActivePoint.get_CodeElement(vsCMElement.vsCMElementClass);
      // Display the fullname of CodeClass object.
      MessageBox.Show(objCodeCls.FullName);
      // Prove that the parent object of a CodeClass is a CodeElement.
      objCodeElem = (CodeElement)objCodeCls.Parent;
      // Get access privilege for CodeClass.
      MessageBox.Show(objCodeCls.Access.ToString());
      // Change access privilege for CodeClass objCodeCls.
      // Note the change in access keyword in your code document.
      objCodeCls.Access = vsCMAccess.vsCMAccessPublic;
   }
   catch (Exception ex)
   { 
      MessageBox.Show(ex.Message);
   }

Zabezpieczenia programu .NET Framework

Zobacz też

Informacje

CodeClass Interfejs

Przestrzeń nazw EnvDTE

Inne zasoby

Porady: kompilowanie i uruchamianie kodu modelu obiektów automatyzacji — przykłady

Odnajdowanie kodu za pomocą modelu kodu (Visual Basic)

Odnajdowanie kodu za pomocą modelu kodu (Visual C#)