您的位置:首页 > 其它

.NET 自定义注释格式&快捷注释宏

2010-07-27 17:02 141 查看
1.创建宏

2.编辑宏

3.代码
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics

'///-----------------------------------------------------------------
'///<copyright> Copyright (c) 2009,xxx有限公司 All rights reserved.</copyright>
'///<summary>
'/// KP
'///</summary>
'///<current_version>1.0.0.1</current_version>
'///<author>BLACK</author>
'///<finish_date></finish_date>
'///<modify>BLACK</modify>
'///<modify_date></modify_date>
'///-----------------------------------------------------------------
Public Module KP

Private Function Copyright()
Copyright = "Copyright (c) " + CStr(Date.Today.Year) + ",XXXX有限公司 All rights reserved."
End Function

Private Function EMailAddress()
EMailAddress = "XXX@XXX.com"
End Function

Private Function AuthorName()
AuthorName = "XXX"
End Function

Function ProductName()
ProductName = ""
End Function

Private Function GenGUIDString() As String
Dim sGUID As String
sGUID = System.Guid.NewGuid.ToString()
sGUID = UCase(sGUID.Replace("-", "_"))
GenGUIDString = sGUID
End Function

Private Function FileString(ByVal filename As String) As String
FileString = UCase(filename.Replace(".", "_"))
UCase(Left(ActiveDocument.Name, Len(ActiveDocument.Name) - 2))
End Function

Sub ClassTitleTemplate()
Dim lens = 0
Dim strDesc = vbLf + "///------------------------------------------------------------------------------" + vbLf + _
"Copyright:" + Copyright() + vbLf + _
"描  述:" + vbLf + _
"版本号:1.0.0.1" + vbLf + _
"作  者:" + AuthorName() + " (" + EMailAddress() + ")" + vbLf + _
"日  期:" + FormatDateTime(Date.Today, 1) + vbLf + _
"修  改:" + vbLf + _
"原  因:" + vbLf + _
"------------------------------------------------------------------------------"

'ActiveDocument.Selection.StartOfDocument(0)
ActiveDocument.Selection.text() = strDesc
End Sub

'///<current_version>1.0.0.1</current_version>
'///<author>xxx</author>
'///<finish_date>20100727</finish_date>
'///<modify>xxx</modify>
'///<modify_date>20100727</modify_date>
'///-----------------------------------------------------------------
Sub FunctionTitleTemplate()
Dim Descr = "///" + "描  述:" + vbLf + _
"作  者:" + AuthorName() + " (" + EMailAddress() + ")" + vbLf + _
"时  间:" + FormatDateTime(Date.Today, 1) + vbLf + _
"修  改:" + vbLf + _
"原  因:"

' ActiveDocument.Selection.StartOfDocument(0)
ActiveDocument.Selection.text = Descr
End Sub

'签名
Private Function Myname() As String
Dim Descr = AuthorName() + " (" + EMailAddress() + ")"
End Function

Private Function Curdate() As String
Dim Descr = FormatDateTime(Date.Today, 1)
End Function

'修改者签名
Sub Modify()
Dim Descr = AuthorName() + " (" + EMailAddress() + ")" + " " + FormatDateTime(Date.Today, 1)
ActiveDocument.Selection.text = Descr
End Sub

End Module


4.工具-选项-键盘

5.搜索宏

6.宏与事件绑定。

效果:

/// <summary>
/// ------------------------------------------------------------------------------
/// Copyright:Copyright (c) 2010,xxx限公司 All rights reserved.
/// 描  述:
/// 版本号:1.0.0.1
/// 作  者:xxx (xxx@xxx.com)
/// 日  期:2010年7月27日
/// 修  改:
/// 原  因:
/// ------------------------------------------------------------------------------
/// </summary>
public class ConnectDB : DBOBase
{
#region [私有变量]

#endregion
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐