它是一個視覺工作室宏,最初來自JP Boodhoo的Nothing But .NET Boot Camp類。這是它:
Sub ConvertLine()
If DTE.ActiveDocument Is Nothing Then Return
Dim isOpen As Boolean = OpenUndo("ConvertLine")
Dim selection As TextSelection = CType(DTE.ActiveDocument.Selection(), EnvDTE.TextSelection)
selection.SelectLine()
If selection.Text = "" Then Return
Dim classKeyword As String = "class """
Dim methodKeyword As String = "void """
Dim classIndex As Integer = selection.Text.IndexOf(classKeyword)
Dim methodIndex As Integer = selection.Text.IndexOf(methodKeyword)
If classIndex + methodIndex < 0 Then Return
Dim index = CType(IIf(classIndex >= 0, classIndex, methodIndex), Integer)
Dim prefix = selection.Text.Substring(0, index) + CType(IIf(classIndex >= 0, classKeyword, methodKeyword), String)
Dim description As String = selection.Text.Replace(prefix, String.Empty)
Dim conversion As String = Common.ReplaceSpacesWithUnderscores(description)
conversion = Common.ReplaceApostrophesWithUnderscores(conversion)
conversion = Common.ReplaceQuotesWithUnderscores(conversion)
selection.Text = prefix.Replace("""", String.Empty) + conversion
If prefix.Contains(methodKeyword) Then selection.LineDown() Else selection.LineUp()
selection.EndOfLine()
CloseUndo(isOpen)
End Sub
我們也可以知道此屏幕錄像的網址嗎? – 2010-06-27 20:36:26
我不認爲我能找到它。但是我做了http://www.iamnotmyself.com/2009/10/23/TDDKataCalculatorDemonstration.aspx。也許它有音頻?不在我的機器上。 – 2010-06-27 20:47:07