CodeClass2.RemoveInterface 方法 (Object)
從實作介面清單中移除介面。
命名空間: EnvDTE80
組件: EnvDTE80 (在 EnvDTE80.dll 中)
語法
'宣告
Sub RemoveInterface ( _
Element As Object _
)
void RemoveInterface(
Object Element
)
void RemoveInterface(
Object^ Element
)
abstract RemoveInterface :
Element:Object -> unit
function RemoveInterface(
Element : Object
)
參數
- Element
型別:System.Object
必要項。CodeElement 或集合中某一項目的名稱。
備註
從 ImplementedInterfaces 集合中移除程式碼項目。 這個項目可以是集合中某個 CodeElement 物件,也可以是集合中某個唯一項目的名稱。
注意事項 |
---|
在特定類型的編輯之後,程式碼模型項目 (例如類別、結構、函式、屬性、委派等) 的值可能不具決定性,表示其值不一定維持相同。如需詳細資訊,請參閱使用程式碼模型探索程式碼 (Visual Basic) 的<程式碼模型項目值可以變更>一節。 |
範例
[Visual Basic]
Sub RemoveInterfaceExample(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)
If MsgBox("Remove all interfaces from " & cls.Name & "?", _
MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
Dim intrface As CodeElement
For Each intrface In cls.ImplementedInterfaces
cls.RemoveInterface(intrface)
Next
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Function ConvertFullName(ByVal cm As CodeModel, _
ByVal fullName As String) As String
' Convert a .NET type name into a C++ type name.
If (cm.Language = CodeModelLanguageConstants.vsCMLanguageVC) Or _
(cm.Language = CodeModelLanguageConstants.vsCMLanguageMC) Then
Return fullName.Replace(".", "::")
Else
Return fullName
End If
End Function
[C#]
public void RemoveInterfaceExample(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);
if (MessageBox.Show("Remove all interfaces from " + cls.Name +
"?", "", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
foreach (CodeInterface intrface in
cls.ImplementedInterfaces)
cls.RemoveInterface(intrface);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
string ConvertFullName(CodeModel cm, string fullName)
{
// Convert a .NET type name into a C++ type name.
if ((cm.Language == CodeModelLanguageConstants.vsCMLanguageVC) ||
(cm.Language == CodeModelLanguageConstants.vsCMLanguageMC))
return fullName.Replace(".", "::");
else
return fullName;
}
.NET Framework 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。