ProjectItem.FileCodeModel 属性
获取项目项的 FileCodeModel 对象。
命名空间: EnvDTE
程序集: EnvDTE(在 EnvDTE.dll 中)
语法
声明
ReadOnly Property FileCodeModel As FileCodeModel
Get
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 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。