Debug.getSwitch

Overview | Methods | This Package | All Packages

Debug.getSwitch

Retrieves the value for the specified switch.

Syntax

public static boolean getSwitch( String name )

Parameters

name

The name of the switch. This performs a lookup for the actual switch object.

Return Value

Returns true if the switch is set; otherwise, returns false. If the switch name cannot be found, returns false.

Remarks

A switch is a debugging tool that allows you to dynamically swap bits of logic in and out of code. For example, you may have logic in your code that prints information every time part of your application paints so you can see when and why it is painting. However, you probably don't want to see an endless stream of text displayed all the time. You can use switches to add your special logic but keep it from being invoked unless you need it. You can dynamically switch logic on and off without recompiling.

A switch can be set either from the registry or from an environment variable. To set a switch from the registry, type the switch name as a non-zero DWORD value under the key HKEY_CURRENT_USER\Software\Microsoft\WFC\DebugSwitches. To set a switch from the environment, set an environment variable named WFCD_switchName to either 1 or Y.

Note  Switches always return false in retail builds, but it is a good idea to wrap your code in a #IF Debug clause to reduce the size of your class file.