public class BooleanSwitch : Switch
|
You must enable tracing or debugging to use a switch. The following syntax is compiler specific. If you use compilers other than C# or Visual Basic, refer to the documentation for your compiler.
To set the level of your BooleanSwitch, edit the configuration file corresponding to the name of your application. Within this file, you can add a switch and set its value, remove a switch, or clear all switches previously set by the application. The configuration file should be formatted like the following example:
<configuration> <system.diagnostics> <switches> <add name="mySwitch" value="10" /> <add name="myNewSwitch" value="20" /> <remove name="mySwitch" /> <clear/> </switches> </system.diagnostics> </configuration>
Main
method passes its location to
MyMethod
, which prints an error message and where the error occurred.// Class level declaration. /* Create a BooleanSwitch for data. This switch is enabled by using values * stored in the Registry or in environmental variables. */ static BooleanSwitch dataSwitch = new BooleanSwitch("Data", "DataAccess module"); static public void MyMethod(string location) { //Insert code here to handle processing. if(dataSwitch.Enabled) Console.WriteLine("Error happened at " + location); } public static void Main(string[] args) { //Run the method which writes an error message specifying the location of the error. MyMethod("in Main"); }
ctor #1 | Initializes a new instance of the BooleanSwitch class. |
Description (inherited from System.Diagnostics.Switch) |
Read-only See base class member description: System.Diagnostics.Switch.Description Gets a description of the switch. |
DisplayName (inherited from System.Diagnostics.Switch) |
Read-only See base class member description: System.Diagnostics.Switch.DisplayName Gets a name used to identify the switch. |
Enabled | Read-write Specifies whether the switch is enabled or disabled. |
Equals (inherited from System.Object) |
See base class member description: System.Object.Equals Derived from System.Object, the primary base class for all objects. |
GetHashCode (inherited from System.Object) |
See base class member description: System.Object.GetHashCode Derived from System.Object, the primary base class for all objects. |
GetType (inherited from System.Object) |
See base class member description: System.Object.GetType Derived from System.Object, the primary base class for all objects. |
ToString (inherited from System.Object) |
See base class member description: System.Object.ToString Derived from System.Object, the primary base class for all objects. |
SwitchSetting (inherited from System.Diagnostics.Switch) |
Read-write See base class member description: System.Diagnostics.Switch.SwitchSetting Gets or sets the current setting for this switch. |
Finalize (inherited from System.Object) |
See base class member description: System.Object.Finalize Derived from System.Object, the primary base class for all objects. |
MemberwiseClone (inherited from System.Object) |
See base class member description: System.Object.MemberwiseClone Derived from System.Object, the primary base class for all objects. |
OnSwitchSettingChanged (inherited from System.Diagnostics.Switch) |
See base class member description: System.Diagnostics.Switch.OnSwitchSettingChanged Raises the SwitchSettingChanged event. |
Hierarchy:
displayName
description
To set the level of your BooleanSwitch, edit the configuration file corresponding to the name of your application. Within this file, you can add a switch and set its value, remove a switch, or clear all switches previously set by the application. The configuration file should be formatted like the following example:
<configuration> <system.diagnostics> <switches> <add name="mySwitch" value="10" /> <add name="myNewSwitch" value="20" /> <remove name="mySwitch" /> <clear/> </switches> </system.diagnostics> </configuration>
Main
method passes its location to
MyMethod
, which prints an error message and where the error occurred.// Class level declaration. /* Create a BooleanSwitch for data. This switch is enabled by using values * stored in the Registry or in environmental variables. */ static BooleanSwitch dataSwitch = new BooleanSwitch("Data", "DataAccess module"); static public void MyMethod(string location) { //Insert code here to handle processing. if(dataSwitch.Enabled) Console.WriteLine("Error happened at " + location); } public static void Main(string[] args) { //Run the method which writes an error message specifying the location of the error. MyMethod("in Main"); }
public string Description {get;}
|
public string DisplayName {get;}
|
public bool Enabled {get; set;}
|
Main
method passes its location to
MyMethod
, which prints an error message and the location where the error occurred.//Class level declaration. /* Create a BooleanSwitch for data. This switch is enabled by using values * stored in the Registry or in environmental variables. */ static BooleanSwitch dataSwitch = new BooleanSwitch("Data", "DataAccess module"); static public void MyMethod(string location) { //Insert code here to handle processing. if(dataSwitch.Enabled) Console.WriteLine("Error happened at " + location); } public static void Main(string[] args) { //Run the method that writes an error message specifying the location of the error. MyMethod("in Main"); }
protected int SwitchSetting {get; set;}
|
~BooleanSwitch(); |
public virtual int GetHashCode(); |
public Type GetType(); |
protected object MemberwiseClone(); |
protected virtual void OnSwitchSettingChanged(); |
public virtual string ToString(); |