Tool or script to wrap procedure in a #region?

A

Alvin Bruney - ASP.NET MVP

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
 
V

vbMark

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
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 
D

Denis Dougall

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
 
C

Chris Dunaway

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top