CodeAttributeArgument.Kind 屬性
取得列舉值,定義程式碼項目的型別。
命名空間: EnvDTE80
組件: EnvDTE80 (在 EnvDTE80.dll 中)
語法
'宣告
ReadOnly Property Kind As vsCMElement
Get
vsCMElement Kind { get; }
property vsCMElement Kind {
vsCMElement get ();
}
abstract Kind : vsCMElement
function get Kind () : vsCMElement
屬性值
型別:EnvDTE.vsCMElement
vsCMElement 值。
備註
注意事項 |
---|
在特定類型的編輯之後,程式碼模型項目 (例如類別、結構、函式、屬性、委派等) 的值可能不具決定性,表示其值不一定維持相同。 如需詳細資訊,請參閱使用程式碼模型探索程式碼 (Visual Basic) 的<程式碼模型項目值可以變更>一節。 |
範例
' Macro code.
Sub codeArgNameExample()
Dim sel As TextSelection = _
CType(DTE.ActiveDocument.Selection, TextSelection)
Dim cls As CodeClass2 = CType(sel.ActivePoint. _
CodeElement(vsCMElement.vsCMElementClass), CodeClass2)
Dim attr As CodeAttribute2
Dim attrArg As CodeAttributeArgument
Dim msg As String
Try
' Loop through all of the attributes in the class.
For Each attr In cls.Attributes
' Loop through all of the arguments for the attribute.
For Each attrArg In attr.Arguments
msg += "Value: " & attrArg.Value & " " & vbCr
' If the argument has a name, list it.
If attrArg.Name <> Nothing Then
msg += "Name: " & attrArg.Name & vbCr
End If
msg += "Arg start pos: " & _
attrArg.StartPoint.LineCharOffset & vbCr
msg += "Arg end pos: " & _
attrArg.EndPoint.LineCharOffset & vbCr
Next
Next
msg += "Location: " & attrArg.InfoLocation.ToString & vbCr
msg += "Is code type? " & attrArg.IsCodeType.ToString & vbCr
msg += "Code element type: " & attrArg.Kind.ToString & vbCr
msg += "Language: " & attrArg.Language & vbCr
msg += ("Name of attribute's project item: " & _
attrArg.ProjectItem.Name)
' List the arguments for the attribute.
MsgBox("Attribute parameters for " & attr.Name _
& ": " & vbCr & msg)
Catch ex As System.Exception
MsgBox("ERROR -> " & ex.Message)
End Try
End Sub
.NET Framework 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。