ProjectItem.FileCodeModel 屬性
取得專案項目的 FileCodeModel 物件。
命名空間: EnvDTE
組件: EnvDTE (在 EnvDTE.dll 中)
語法
'宣告
ReadOnly Property FileCodeModel As FileCodeModel
FileCodeModel FileCodeModel { get; }
property FileCodeModel^ FileCodeModel {
FileCodeModel^ get ();
}
abstract FileCodeModel : FileCodeModel
function get FileCodeModel () : FileCodeModel
屬性值
型別:EnvDTE.FileCodeModel
FileCodeModel 物件。
備註
唯有專案項目是程式碼檔案,而且位於實作 Visual Studio 程式碼模型的專案中時,才會為專案項目傳回 FileCodeModel 物件。
範例
Sub FileCodeModelExample()
' This goes through the current document using the Visual Studio
' Code Model to add documentation style comments to each function
' similar to the Visual C# documenation comments.
Dim projitem As ProjectItem = DTE.ActiveDocument.ProjectItem
Dim filecm As FileCodeModel = projitem.FileCodeModel
Dim celt As CodeElement = filecm.CodeElements.Item(1)
Dim celttype As CodeType = CType(celt, CodeType)
Dim ep As EditPoint = celttype.GetStartPoint(vsCMPart.vsCMPartHeader).CreateEditPoint()
For Each celt In celttype.Members
If (celt.Kind = vsCMElement.vsCMElementFunction) Then
' Get Params.
Dim codefun As CodeFunction = celt
ep.MoveToPoint(codefun.GetStartPoint(vsCMPart.vsCMPartHeader))
Dim params As CodeElements = codefun.Parameters
' Do comment.
ep.Insert(Microsoft.VisualBasic.Constants.vbCrLf)
ep.LineUp()
' ep.Indent(Nothing) ' shouldn't need to pass Nothing.
ep.Insert(Microsoft.VisualBasic.Constants.vbTab & "''' <summary>")
ep.Insert(Microsoft.VisualBasic.Constants.vbCrLf)
ep.Insert(Microsoft.VisualBasic.Constants.vbTab & "''' Summary of this sub.")
ep.Insert(Microsoft.VisualBasic.Constants.vbCrLf)
ep.Insert(Microsoft.VisualBasic.Constants.vbTab & "''' <summary>")
ep.Insert(Microsoft.VisualBasic.Constants.vbCrLf)
ep.Insert(Microsoft.VisualBasic.Constants.vbTab & "''' ")
Dim celt2 As CodeElement
Dim cp As CodeParameter
For Each celt2 In params
cp = celt2
ep.Insert("<param name=" & cp.Name & "></param>")
ep.Insert(Microsoft.VisualBasic.Constants.vbCrLf)
ep.Insert(Microsoft.VisualBasic.Constants.vbTab & "''' ")
Next
End If
Next
End Sub
.NET Framework 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。