Sub PropertyGenerator()Sub PropertyGenerator() Dim form As Form form =New Form form.TopMost =True form.Controls.Add(New TextBox) form.Controls.Add(New TextBox) form.Controls(0).Text ="type" form.Controls(1).Text ="name" form.Controls(0).Dock = DockStyle.Bottom form.Controls(1).Dock = DockStyle.Bottom form.ShowDialog() Dim type AsString Dim name AsString Dim capitaledName AsString type = form.Controls(0).Text name = form.Controls(1).Text capitaledName =Char.ToUpper(name.Chars(0)) & name.Substring(1) form =Nothing DTE.ActiveDocument.Selection.Text ="private "& type &""& name &";" DTE.ActiveDocument.Selection.NewLine() DTE.ActiveDocument.Selection.NewLine() DTE.ActiveDocument.Selection.Text ="public "& type &""& capitaledName &"" DTE.ActiveDocument.Selection.NewLine() DTE.ActiveDocument.Selection.Text ="{" DTE.ActiveDocument.Selection.NewLine() DTE.ActiveDocument.Selection.Text ="get {return this."& name &";}" DTE.ActiveDocument.Selection.NewLine() DTE.ActiveDocument.Selection.Text ="set {this."& name &" = value;}" DTE.ActiveDocument.Selection.NewLine() DTE.ActiveDocument.Selection.Text ="}" DTE.ActiveDocument.Selection.NewLine() End Sub
Dim line AsString With DTE.ActiveDocument.Selection line = .Text EndWith Dim parts AsString() parts = line.Split("") IfNot parts.Length =3Then Exit Sub EndIf Dim type AsString Dim name AsString Dim capitaledName AsString type = parts(1) name = parts(2).Replace(";", "") capitaledName =Char.ToUpper(name.Chars(0)) & name.Substring(1) DTE.ActiveDocument.Selection.Text ="private "& type &""& name &";" DTE.ActiveDocument.Selection.NewLine() DTE.ActiveDocument.Selection.NewLine() DTE.ActiveDocument.Selection.Text ="public "& type &""& capitaledName &"" DTE.ActiveDocument.Selection.NewLine() DTE.ActiveDocument.Selection.Text ="{" DTE.ActiveDocument.Selection.NewLine() DTE.ActiveDocument.Selection.Text ="get {return this."& name &";}" DTE.ActiveDocument.Selection.NewLine() DTE.ActiveDocument.Selection.Text ="set {this."& name &" = value;}" DTE.ActiveDocument.Selection.NewLine() DTE.ActiveDocument.Selection.Text ="}" DTE.ActiveDocument.Selection.NewLine()