CodeClass2.ImplementedInterfaces 属性
获取此代码类实现的接口的集合。
命名空间: EnvDTE80
程序集: EnvDTE80(在 EnvDTE80.dll 中)
语法
声明
ReadOnly Property ImplementedInterfaces As CodeElements
CodeElements ImplementedInterfaces { get; }
property CodeElements^ ImplementedInterfaces {
CodeElements^ get ();
}
abstract ImplementedInterfaces : CodeElements with get
function get ImplementedInterfaces () : CodeElements
属性值
类型:CodeElements
一个 CodeElements 集合。
备注
ImplementedInterfaces 属性返回一个 CodeElements 集合。 每个元素的类型均为 vsCMElementInterface(请参见 vsCMElement)并表示代码类实现的接口。
备注
在进行某些类型的编辑之后,代码模型元素(如类、结构、函数、特性、委托等)的值可能是非确定性的,这意味着不能指望它们的值总是保持不变。有关更多信息,请参见 使用代码模型查找代码 (Visual Basic) 中的“代码模型元素的值可能会更改”一节。
示例
[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);
}
}
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关详细信息,请参阅通过部分受信任的代码使用库。