TextPoint.CodeElement Özellik
Kod öğesi adresindeki verir TextPoint konum.
Ad alanı: EnvDTE
Derleme: EnvDTE (EnvDTE.dll içinde)
Sözdizimi
'Bildirim
ReadOnly Property CodeElement ( _
Scope As vsCMElement _
) As CodeElement
CodeElement this[
vsCMElement Scope
] { get; }
property CodeElement^ CodeElement[[InAttribute] vsCMElement Scope] {
CodeElement^ get ([InAttribute] vsCMElement Scope);
}
abstract CodeElement :
Scope:vsCMElement -> CodeElement with get
JScript dizini oluşturulan özellikleri desteklemez.
Parametreler
Scope
Tür: EnvDTE.vsCMElementGerekli.A vsCMElement kod öğesi Düzenleyicisi konum içeren belirtilen tür ile belirten sabit.
Özellik Değeri
Tür: EnvDTE.CodeElement
CodeElement nesnesi
Notlar
Belirtilen kod öğesi türü olmadığından, TextPoint konum, daha sonra CodeElement döndüren Nothing.CodeElementiçin bir kısayol TextPoint.Parent.Parent.ProjectItem.CodeModel.CodeElementFromPoint(TextPoint, <scope>).
Örnekler
Sub CodeElementExample(ByVal dte As DTE2)
' Before running this example, open a code document from a project
' and place the insertion point anywhere inside the source code.
Try
Dim sel As TextSelection = _
CType(dte.ActiveDocument.Selection, TextSelection)
Dim pnt As TextPoint = CType(sel.ActivePoint, TextPoint)
' Discover every code element containing the insertion point.
Dim elems As String
Dim elem As CodeElement
Dim scope As vsCMElement
For Each scope In [Enum].GetValues(scope.GetType())
elem = pnt.CodeElement(scope)
If IsNothing(elem) = False Then
elems &= elem.Name & _
" (" & scope.ToString() & ")" & vbCrLf
End If
Next
MsgBox("The following elements contain the insertion point:" _
& vbCrLf & vbCrLf & elems)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
public void CodeElementExample(DTE2 dte)
{
// Before running this example, open a code document from a project
// and place the insertion point anywhere inside the source code.
try
{
TextSelection sel =
(TextSelection)dte.ActiveDocument.Selection;
TextPoint pnt = (TextPoint)sel.ActivePoint;
// Discover every code element containing the insertion point.
string elems = "";
vsCMElement scopes = 0;
foreach (vsCMElement scope in Enum.GetValues(scopes.GetType()))
{
CodeElement elem = pnt.get_CodeElement(scope);
if (elem != null)
elems += elem.Name +
" (" + scope.ToString() + ")\n";
}
MessageBox.Show(
"The following elements contain the insertion point:\n\n"
+ elems);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
.NET Framework Güvenliği
- Anında arayanlar için tam güven. Bu üye kısmen güvenilen kodla kullanılamaz. Daha fazla bilgi için bkz. Kısmen Güvenilen Koddan Kitaplıkları Kullanma.
Ayrıca bkz.
Başvuru
Diğer Kaynaklar
Nasıl yapılır: Otomasyon Nesne Modeli Kod Örnekleri Derleme ve Çalıştırma