KnowDotNet NetRefactor

Net Sessions - Manage ASP.NET Session Variables

Using Enums for Session Variables

Session Variables can be created and maintained as Enum Variables. This is a method that has been in use by some developers, just as Strings, Consts, and possibly even Properties. Figure 1 shows the Refresh Sesson Variables Dialog with the Enum Option set. To create the Enum Variables, you must create an Empty Enum as shown in Figure 1. Place your cursor inside the enum and click the Create Variables button.   Net Sessions is available for purchase or Free 30 Day Trial.  Click here to download.

Figure 1 - Creating Enum Variables.

Enum Variables


After you click the Create Button, you will see the variables created as shown in Figure 2.

Figure 2 - Enum Variables Created.

Enum Variables


Once you have created the Enum Variables, you can then click the Convert Variables and Net Sessions will convert all references to Session Variables to use the newly created Enum Variables as shown in Figure 3.

Figure 3 - Session Variables Referenced as Enums.

Enum Variables


With Enum variables, it is required to use the ToString() method of the desired Enum Variable. This is a minor drawback to utilization of Enums as Session Variables.
Intellisense is available with Enum variables, just as it is available with Consts and Properties, as shown in Figure 4.

Figure 4 - Intellisense with Enum Session Variables.

Enum Variables

Refresh Variables Dialog


The Maintenance Dialog is invoked from the Net Sessions context menu by selecting the Refresh Variable Collection by Scan. When this option is selected, the Maintenace dialog shown in Figure 1 will be displayed.

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