Aracılığıyla paylaş


CodeDelegate2.InfoLocation Özellik

Kod modeli yeteneklerini temsilcisi alır.

Ad alanı:  EnvDTE80
Derleme:  EnvDTE80 (EnvDTE80.dll içinde)

Sözdizimi

'Bildirim
ReadOnly Property InfoLocation As vsCMInfoLocation
    Get
vsCMInfoLocation InfoLocation { get; }
property vsCMInfoLocation InfoLocation {
    vsCMInfoLocation get ();
}
abstract InfoLocation : vsCMInfoLocation
function get InfoLocation () : vsCMInfoLocation

Özellik Değeri

Tür: EnvDTE.vsCMInfoLocation
A vsCMInfoLocation sabit değeri.

Yüklenen

CodeDelegate.InfoLocation

Açıklamalar

InfoLocation Verir vsCMInfoLocationProject, özelliklerini ayarlayabilir ardından elde bir StartPointve bir EndPoint. Başka bir (b) (a) bir kod modeli nesneden geçerken — bu tür bir işlev türünü veya onun temel sınıfı için bir sınıftan itibaren — b tipi olabilir vsCMInfoLocationExternal tanımına olduğunda başka bir proje. Disposition kod modeli uygulamasına bağlıdır, A'ın aynı dilde uygulanan nesne B'nin proje olup olmadığını nesne

InfoLocation Verir vsCMInfoLocationExternal, daha sonra bilgileri kullanılabilir yalnızca meta veriler, bir dll İnceleme veya dondurulmuş kaynakları. Elde etmek mümkün olabilir bir StartPoint ve EditPoint2, ancak; belgeyi düzenleyemez yani, özelliklerini ayarlamak veya kod öğesi arkasında değiştirin.

InfoLocation Verir vsCMInfoLocationNone, sonra tüm kullanılabilir olan bir kod modeli nesnesi olan adı. Ayrıca, bazı durumlarda kaynak kodu bağlamında dayanarak, bir sınıf veya Arabirim adı olmayacağını söyleyebilir. Kod modeli herhangi kullanışlı bir bilgi adı çözülemedi çünkü bu durumda, ancak, aksi takdirde yararsız nesnesidir.

Not

Sınıflar, yapılar, işlevleri, öznitelikleri, Temsilciler ve benzeri gibi kod modeli öğeleri değerlerini düzenlemeleri değerlerine bağlı her zaman aynı kalmasını dayanıyordu olamaz, diğer bir deyişle, belirli türde yaptıktan sonra non-deterministik olabilir. Daha fazla bilgi için bkz: kod modeli öğe değerlerini de değiştirebilirsiniz bölüm Kod modeli (@) kullanarak kodu keşfetme.

Örnekler

Bu örnek çalıştırmadan, bir sınıf içeren bir proje yük ve örnek kod ile birlikte aşağıdaki satırı ekleyin. Hem satır hem de örnek kod eklendikten sonra tıklatın Delegate satır, ekleme noktasını yerleştirmek ve sonra çalışma örneği.

[VisualBasic]

Delegate Sub MySubDelegate(ByVal x As Integer)

[C#]

public delegate void MySubDelegate(int x);

[VisualBasic]

Public Sub CodeDelegateExample(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
        ' Retrieve the CodeClass at the insertion point.
        Dim sel As TextSelection = _
            CType(DTE.ActiveDocument.Selection, TextSelection)
        Dim del As CodeDelegate2 = _
            CType(sel.ActivePoint.CodeElement( _
        vsCMElement.vsCMElementDelegate), CodeDelegate2)
        Dim elem As CodeElement2
        Dim sb As New System.Text.StringBuilder

        ' Display the baseclass name of the delegate.
        sb.AppendLine("Delegate base class name: " & _
          del.BaseClass.Name)
        sb.AppendLine("Delegate's access: " & del.Access.ToString)
        sb.AppendLine("Children: " & del.Children.Count & "  _
          Name: " & del.Children.Item(1).Name)
        sb.AppendLine("Collection: " & del.Collection.Count)
        sb.AppendLine("Delegates:")
        For Each elem In del.Collection
            sb.AppendLine("    - " & elem.Name)
        Next
        sb.AppendLine("Comment: " & del.Comment)
        sb.AppendLine("Doc Comment: " & del.DocComment)
        sb.AppendLine("DTE Parent: " & del.DTE.Name)
        sb.AppendLine("Endpoint location: " & _
          del.EndPoint.AbsoluteCharOffset)
        sb.AppendLine("Infolocation: " & del.InfoLocation.ToString)
        sb.AppendLine("Can provide CodeType object? " & _
          del.IsCodeType.ToString)
        sb.AppendLine("Is Delegate derived? " & _
          del.IsDerivedFrom("EnvDTE80"))
        sb.AppendLine("Is Delegate a generic? " & del.IsGeneric)
        sb.AppendLine("Kind: " & del.Kind.ToString)
        sb.AppendLine("Authoring language: " & _
          del.Language.ToString)
        sb.AppendLine("Name: " & del.Name)
        sb.AppendLine("Namespace: " + del.Namespace.Name);
        sb.AppendLine("Parameters: " & del.Parameters.Item(1).Name)
        sb.AppendLine("Project containing the delegate: " & _
          del.ProjectItem.Name)
        sb.AppendLine("Prototype for delegate: " & del.Prototype)
        sb.AppendLine("Delegate start point offset: " & _
          del.StartPoint.LineCharOffset)
        sb.AppendLine("Type: " & del.Type.TypeKind.ToString)
        MsgBox(sb.ToString)

    Catch ex As System.Exception
        MsgBox(ex.ToString)
    End Try
End Sub

[C#]

public void CodeDelegateExample(DTE2 DTE)
{
    try
    {
        // Retrieve the CodeClass at the insertion point.
        TextSelection sel = (TextSelection) 
          DTE.ActiveDocument.Selection;
        CodeDelegate2 del = (CodeDelegate2) 
          sel.ActivePoint.get_CodeElement
          (vsCMElement.vsCMElementDelegate);
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        // Display the baseclass name of the delegate.
        sb.AppendLine("Delegate base class name: " + 
          del.BaseClass.Name);
        sb.AppendLine("Delegate's access: " + del.Access);
        sb.AppendLine("Children: "+del.Children.Count+"  Name: 
          "+del.Children.Item(1).Name);
        sb.AppendLine("Collection: "+del.Collection.Count);
        sb.AppendLine("Delegates:");
        foreach (CodeElement2 elem in del.Collection )
        {
            sb.AppendLine("    - "+elem.Name);
        }
        sb.AppendLine("Comment: "+del.Comment);
        sb.AppendLine("Attributes:"); 
        foreach (CodeElement2 elem in del.Attributes)
        {
            sb.AppendLine("    - " + elem.Name);
        }
        sb.AppendLine("Bases:");
        foreach (CodeElement2 elem in del.Bases)
        {
            sb.AppendLine("    - " + elem.Name);
        } 
        sb.AppendLine("Doc Comment: " + del.DocComment);
        sb.AppendLine("DTE Parent: "+del.DTE.Name);
        sb.AppendLine("Endpoint location: 
          "+del.EndPoint.AbsoluteCharOffset);
        sb.AppendLine("Infolocation: "+del.InfoLocation);
        sb.AppendLine("Can provide CodeType object? "+del.IsCodeType);
        sb.AppendLine("Is Delegate derived? 
          "+del.get_IsDerivedFrom("EnvDTE80"));
        sb.AppendLine("Is Delegate a generic? "+del.IsGeneric);
        sb.AppendLine("Kind: "+del.Kind);
        sb.AppendLine("Authoring language: "+del.Language);
        sb.AppendLine("Name: "+del.Name);
        sb.AppendLine("Parameters: "+del.Parameters.Item(1).Name);
        sb.AppendLine("Namespace: " + del.Namespace.Name);
        sb.AppendLine("Project containing the delegate: 
          "+del.ProjectItem.Name);
        sb.AppendLine("Delegate start point offset: 
          "+del.StartPoint.LineCharOffset);
        sb.AppendLine("Type: "+del.Type.TypeKind);
          MessageBox.Show(sb.ToString());
    }
    catch(System.Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

.NET Framework Güvenliği

Ayrıca bkz.

Başvuru

CodeDelegate2 Arabirim

InfoLocation Fazla Yük

EnvDTE80 Ad Alanı

Diğer Kaynaklar

Nasıl Yapılır: derlemek ve otomasyon nesne modeli kod örnekleri çalıştırma

Kod modeli (@) kullanarak kodu keşfetme

Kod modeli (Visual C#) kullanarak kodu keşfetme