KnowDotNet Visual Organizer

NET Refactor - Wrap Selection

Wrap Selected Block in User-Defined Construct

Wrap Selection is a refactoring feature that automatically wraps or surrounds a selected block of code, such as a For Next, Do While, If Else, etc.  NET Refactor ships with a set of pre-defined constructs, and you may add any number of your own code constructs, in both VB.NET and C#.

To use this feature, simply select a block of code that you wish to wrap.  Next, select the Wrap Selection menu option from the Organizer menu.  At that point the dialog shown in Figure 1 will be displayed.

If you single-click on any item in the dialog, a tool tip will display the code construct that will be pasted by that selection.  Double-clicking the selection will wrap the selected code block and the dialog will be closed.

Figure 1 - Wrap Selection Dialog.

Wrap Selection Dialog


Once you double-click on the desired context, the resulting code block would look like the following:

      Do Until False
         Dim dt As DataTable
         oDA.SendQuery(sql, dt, cs)
         s2 = i
         s.s =
"A"
         b = Options.All
      
Loop

You can set up your own constructs by going to the Setup Snippets menu option.

Writing Add-Ins for Visual Studio .NET
Writing Add-ins for Visual Studio .NET
by Les Smith
Apress Publishing