CodeClass.Kind 屬性
傳回列舉型別,指出物件的型別。
命名空間: EnvDTE
組件: EnvDTE (在 EnvDTE.dll 中)
語法
'宣告
ReadOnly Property Kind As vsCMElement
vsCMElement Kind { get; }
property vsCMElement Kind {
vsCMElement get ();
}
abstract Kind : vsCMElement
function get Kind () : vsCMElement
屬性值
型別:EnvDTE.vsCMElement
vsCMElement 值。
備註
注意事項 |
---|
在特定類型的編輯之後,程式碼模型項目 (例如類別、結構、函式、屬性、委派等) 的值可能不具決定性,表示其值不一定維持相同。如需詳細資訊,請參閱使用程式碼模型探索程式碼 (Visual Basic) 的<程式碼模型項目值可以變更>一節。 |
範例
Public Sub CodeClassExample(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
Dim objTextSel As TextSelection
Dim objCodeCls As CodeClass
Dim objCodeType As CodeType
Dim objCMElem As vsCMElement
objTextSel = CType(dte.ActiveDocument.Selection, TextSelection)
objCodeCls = CType(objTextSel.ActivePoint.CodeElement(vsCMElement.vsCMElementClass), CodeClass)
' Add DocComment to CodeClass objCodeClass.
objCodeCls.DocComment = "<DOC>DocComment for the CodeClass object</DOC>"
MessageBox.Show(objCodeCls.DocComment)
' Test if a CodeType object is obtainable from the CodeClass
If objCodeCls.IsCodeType Then
' then we can cast the CodeClass to a CodeType.
objCodeType = CType(objCodeCls, CodeType)
Else
' The CodeClass object is not a CodeType but is
' some Kind of element.
objCMElem = objCodeCls.Kind
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
public void CodeClassExample(DTE2 dte)
{
// Before running this example, open a code document from a
// project and place the insertion point inside a class definition.
try
{
TextSelection objTextSel;
CodeClass objCodeCls;
CodeType objCodeType;
vsCMElement objCMElem;
objTextSel = (TextSelection)dte.ActiveDocument.Selection;
objCodeCls = (CodeClass)objTextSel.ActivePoint.get_CodeElement(vsCMElement.vsCMElementClass);
// Add DocComment to CodeClass objCodeClass.
objCodeCls.DocComment = "<DOC>DocComment for the CodeClass object</DOC>";
MessageBox.Show(objCodeCls.DocComment);
// Test if a CodeType object is obtainable from the CodeClass
if (objCodeCls.IsCodeType)
{ // then we can cast the CodeClass to a CodeType.
objCodeType = (CodeType)objCodeCls;
}
else // The CodeClass object is not a CodeType but is
{ // some Kind of element.
objCMElem = objCodeCls.Kind;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
.NET Framework 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。