Tool or script to wrap procedure in a #region?

  • Thread starter Thread starter vbMark
  • Start date Start date
Is that so difficult that you need a tool?

#region My Name
public void SomeMethod()
{
}
#endregion

???

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
 
Is that so difficult that you need a tool?

#region My Name
public void SomeMethod()
{
}
#endregion

???

I have a project that is already begun and has many methods already.

(9 out of 10 people on the Internet are wise guys)

--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Best free software
http://www.vbmark.com
Freeware-dedicated search engine
http://www.eurekster.com/parties/Freeware1.htm
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 
I think you got that remark because you have "vb" in front of your name (ie
..Net is to Vb coders what a package of razor blades is to babies)... But
anyways I would suggest you build a DLL with your companys custom methods
and then add a reference to it. Then add ..

#region Using directives
using System;
using System.Data;
using MyCompaniesMethods;
#endregion

to your code.

That would be the best way to bring in all your procedures.

Denis
 
Here is a small macro that will wrap a selection of text in a region.
It uses the word on the first line as the name of the region.

So in the code, type the name of the region on a line by itself before
the code you want to encapsulate. Then select that line and all the
code you want encapsulated and run the macro.

For Example:

Region Name
Public Function Foo()
...
End Function

Becomes:

#Region "Region Name"
Public Function Foo()
...
End Function
#End Region

It's not perfect and I'm sure you can find a way to improve it, but at
least it is a starting point.

Public Sub WrapWithRegion()
Dim ts As TextSelection = CType(DTE.ActiveWindow.Selection,
TextSelection)
Dim start As EditPoint = ts.TopPoint.CreateEditPoint()
Dim endpt As TextPoint = ts.BottomPoint
Dim sb As New StringBuilder

Try
Dim sRegionName As String =
start.GetText(start.LineLength).Trim
start.Delete(start.LineLength)
start.Insert("#Region """ & sRegionName & """" & vbCrLf)
Do While (start.LessThan(endpt))
start.LineDown()
start.StartOfLine()
Loop
start.Insert("#End Region" & vbCrLf)

Catch ex As System.Exception
Debug.WriteLine(ex)
End Try
End Sub
 
Back
Top