Właściwość CodeClass2.ImplementedInterfaces —
Pobiera zbiór interfejsów implementowanych przez klasę kodu.
Przestrzeń nazw: EnvDTE80
Zestaw: EnvDTE80 (w EnvDTE80.dll)
Składnia
'Deklaracja
ReadOnly Property ImplementedInterfaces As CodeElements
CodeElements ImplementedInterfaces { get; }
property CodeElements^ ImplementedInterfaces {
CodeElements^ get ();
}
abstract ImplementedInterfaces : CodeElements with get
function get ImplementedInterfaces () : CodeElements
Wartość właściwości
Typ: CodeElements
A CodeElements kolekcji.
Uwagi
ImplementedInterfaces Właściwość zwraca CodeElements kolekcji.Każdy element jest typu vsCMElementInterface (patrz vsCMElement) i reprezentuje interfejs implementowany przez klasę kodu.
[!UWAGA]
Wartości elementów modelu kodu, takich jak klasy, strukturach, funkcje, atrybuty, delegatów i tak dalej mogą być deterministyczny po dokonaniu niektórych rodzajów modyfikacji, co oznacza, że ich wartości nie mogą być powoływane do zawsze pozostają takie same.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
[Visual Basic]
Sub ImplementedInterfacesExample(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 cls As CodeClass = _
CType(sel.ActivePoint.CodeElement( _
vsCMElement.vsCMElementClass), CodeClass)
' Display the class's implemented interfaces.
Dim ifaces As String
Dim iface As CodeInterface
For Each iface In cls.ImplementedInterfaces
ifaces &= iface.Name & vbCrLf
Next
MsgBox(cls.Name & " implements the following interfaces:" & _
vbCrLf & vbCrLf & ifaces)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
[C#]
public void ImplementedInterfacesExample(DTE2 dte)
{
// 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.
TextSelection sel =
(TextSelection)dte.ActiveDocument.Selection;
CodeClass cls =
(CodeClass)sel.ActivePoint.get_CodeElement(
vsCMElement.vsCMElementClass);
// Display the class's implemented interfaces.
string ifaces = "";
foreach (CodeInterface iface in cls.ImplementedInterfaces)
ifaces += iface.Name + "\n";
MessageBox.Show(cls.Name +
" implements the following interfaces:\n\n" + ifaces);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Zabezpieczenia programu .NET Framework
- Pełne zaufanie do bezpośredniego wywołującego. Tego elementu członkowskiego nie można używać w kodzie częściowo zaufanym. Aby uzyskać więcej informacji, zobacz Używanie bibliotek pochodzących z częściowo zaufanego kodu.
Zobacz też
Informacje
Inne zasoby
Porady: kompilowanie i uruchamianie kodu modelu obiektów automatyzacji — przykłady