System
[00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00]
1.0.3300.0
1.0.5000.0
2.0.0.0
4.0.0.0
Gtk# is thread aware, but not thread safe; See the <link location="node:gtk-sharp/programming/threads">Gtk# Thread Programming</link> for details.
System.Diagnostics.Switch
System.Diagnostics.SwitchLevel(typeof(System.Boolean))
You can use a Boolean trace switch to enable or disable messages based on their importance. Use the property to get the current value of the switch.
You can enable or disable a through the application configuration file and then use the configured value in your application. Alternately, you can create a in your code and set the property directly to instrument a specific section of code.
To configure a , edit the configuration file that corresponds to the name of your application. Within this file, you can add or remove a switch, set a switch's value, or clear all the switches previously set by the application. The configuration file should be formatted like the following example.
<configuration>
<system.diagnostics>
<switches>
<add name="mySwitch" value="1"/>
</switches>
</system.diagnostics>
</configuration>
This example configuration section defines a with the property set to mySwitch and the value set to true. Within your application, you can use the configured switch value by creating a with the same name, as shown in the following code example.
code reference: Classic BooleanSwitch.BooleanSwitch Example#2
By default, the property is set using the value specified in the configuration file. Configure the switch with a value of 0 to set the property to false; configure the switch with a nonzero value to set the property to true. If the constructor cannot find initial switch settings in the configuration file, the property of the new switch is set to false by default.
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 enable debugging in C#, add the /d:DEBUG flag to the compiler command line when you compile your code, or you can add #define DEBUG to the top of your file. In Visual Basic, add the /d:DEBUG=True flag to the compiler command line.
-
To enable tracing in C#, add the /d:TRACE flag to the compiler command line when you compile your code, or add #define TRACE to the top of your file. In Visual Basic, add the /d:TRACE=True flag to the compiler command line.
These debug and trace compiler switches are not required when using the class in isolation. They are only required in conjunction with or methods that are conditionally compiled.
For more information on instrumenting your application, see and . For more information about configuring and using trace switches, see Trace Switches.
To improve performance, you can make members static in your class.
Provides a simple on/off switch that controls debugging and tracing output.
Constructor
1.0.5000.0
2.0.0.0
4.0.0.0
When you create a , the parameter is used to find initial switch settings. If the constructor cannot find initial settings, the property is set to false (disabled).
To set the level of your , 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>
The switches you created should be static.
Initializes a new instance of the class with the specified display name and description.
The name to display on a user interface.
The description of the switch.
Constructor
2.0.0.0
4.0.0.0
The parameter is used to set the value of the property, and the parameter is use to set the value of the property. The parameter is saved as a field and used to initialize the property on first reference. For more information about constructor use, see the constructor.
Initializes a new instance of the class with the specified display name, description, and default switch value.
The name to display on the user interface.
The description of the switch.
The default value of the switch.
Property
1.0.5000.0
2.0.0.0
4.0.0.0
System.Boolean
To be added: an object of type 'bool'
By default, this field is set to false (disabled). To enable the switch, assign this field the value of true. To disable the switch, assign the value to false. The value of this property is determined by the value of the base class property .
This method uses the flag to prevent being called from untrusted code; only the immediate caller is required to have permission. If your code can be called from partially trusted code, do not pass the user input to class methods without validation. For important limitations on using the LinkDemand member, see Demand vs. LinkDemand.
Gets or sets a value indicating whether the switch is enabled or disabled.
Method
2.0.0.0
4.0.0.0
System.Void
The method determines whether the new value is a valid string representation of a Boolean value ("false" or "true"). If so, the method sets the property to 0 or 1. Otherwise, the base method is called, which converts the string value to an integer value, which is then used to set the property.
Determines whether the new value of the property can be parsed as a Boolean value.