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.Object
A switch provides an efficient mechanism for controlling tracing and debugging output at run time using external settings. The class implements default behavior for switches, allowing you to change the switch level at run time.
This class is the base class for the , and the classes. These switches meet most debugging and tracing needs. For more information about trace switches, see Trace Switches.
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 using 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.
To set the level of your switch, edit the configuration file that corresponds to the name of your application. Within this file, you can add a switch and set its value, remove a switch, 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="true" />
</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 Switch Example#4
Provides an abstract base class to create new debugging and tracing switches.
Constructor
1.0.5000.0
2.0.0.0
4.0.0.0
When you create a new object, the value of the parameter is used to find initial switch settings. The default value is an empty string ("").
Within the XML configuration file, you can add a switch and set its value, remove a switch, or clear all the switches previously set by the application. Dynamic changes to the configuration file are not detected while the application is executing. You must stop and restart an application before changes to the configuration file take effect. 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>
Initializes a new instance of the class.
The name of the switch.
The description for 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 the value for the switch if the property is not set by code or by the configuration file attribute. See the overload for additional information.
Initializes a new instance of the class, specifying the display name, description, and default value for the switch.
The name of the switch.
The description of the switch.
The default value for the switch.
Property
2.0.0.0
4.0.0.0
System.Xml.Serialization.XmlIgnore
System.Collections.Specialized.StringDictionary
To be added.
The property identifies the custom attributes referenced in the application's configuration file. Unreferenced custom attributes are not enumerated. Classes that inherit from the class can add custom attributes by overriding the method and returning a string array of custom attribute names.
Gets the custom switch attributes defined in the application configuration file.
Property
1.0.5000.0
2.0.0.0
4.0.0.0
System.String
To be added: an object of type 'string'
This property should indicate the function of the switch; for example, "Enables tracing for a directory watcher component." The value is set by the parameter in the constructor.
Gets a description of the switch.
Property
1.0.5000.0
2.0.0.0
4.0.0.0
System.String
To be added: an object of type 'string'
When you create a new object, the finds initial switch settings. For more information, see the constructor and How to: Configure Trace Switches in the Visual Studio documentation.
Gets a name used to identify the switch.
Method
2.0.0.0
4.0.0.0
System.String[]
The default implementation for the method returns null. If a switch is added in a configuration file and custom attributes are specified that are not included in the string array returned by , a is thrown when the switch is loaded.
Gets the custom attributes supported by the switch.
A string array that contains the names of the custom attributes supported by the switch, or null if there no custom attributes are supported.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Void
is invoked the first time a switch reads the value from the configuration file and is invoked again each time the switch's value is changed.
Invoked when the property is changed.
Method
2.0.0.0
4.0.0.0
System.Void
The default implementation parses the new value of the property to an integer value which it uses to set the property.
Invoked when the property is changed.
Property
1.0.5000.0
2.0.0.0
4.0.0.0
System.Int32
To be added: an object of type 'int'
To be added
Gets or sets the current setting for this switch.
Property
2.0.0.0
4.0.0.0
System.String
To be added.
The method is called when the value of the property is changed. The method parses the value of this property and converts it to an integer value, which is then used to set the property.
Gets or sets the value of the switch.