Compile Code The property definition is often generated based on the defined private variables. This operation can be implemented using the Vs. Net macro, the Code is as follows: Sub temporarymacro () Sub Temporarymacro ()
Dim TS As Textselection = DTE. activedocument. Selection
Dim Insertion As String , Line As String
Dim Lines () As String = TS. Text. Split (vbnewline) ' Returns the attribute process for each row of the selected part.
Insertion = Vbnewline
For Each Line In Lines
Insertion & = Getinsertion (line)
Next
If (Insertion. Length > 1 ) Then
TS. endofline ()
TS. newline ()
TS. insert (insertion)
End If
End sub
Private Function Getinsertion ( Byval Text As String ) As String
Dim Words () As String = Text. Trim. Split ()
If Words. Length < 3 Then ' This row content is not a valid variable Declaration
Return ""
Else
Dim Insertion As String
Insertion & = Vbtab & Vbtab & " /// <Summary> "
Insertion & = Vbnewline
Insertion & = Vbtab & Vbtab & " /// "
Insertion & = Vbnewline
Insertion & = Vbtab & Vbtab & " /// </Summary> " ' If you do not want XML comments, you can skip these lines.
Insertion & = Vbnewline
Insertion & = Vbtab & Vbtab & " Public " & Words ( 1 ) & " " & Words ( 2 ). Trimstart ( " M " ). Trimstart ( " _ " ) .. Trimend ( " ; " ) ' My private variables start with "M _".
Insertion & = Vbnewline
Insertion & = Vbtab & Vbtab & " { "
Insertion & = Vbnewline
Insertion & = Vbtab & Vbtab & Vbtab & " Get {return " & Words ( 2 ) & " } "
Insertion & = Vbnewline
Insertion & = Vbtab & Vbtab & Vbtab & " Set { " & Words ( 2 ). Trimend ( " ; " ) & " = Value ;} "
Insertion & = Vbnewline
Insertion & = Vbtab & Vbtab & " } "
Insertion & = Vbnewline
Return Insertion
End If
End Function
Put the above Code in the Vs. Net macro, select the defined private variable, and then Ctrl + Shift + P to generate the property definition based on the custom private variable.