
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Compiling Blocks of Code Conditionally
|
445
because the base class is the one that receives the initialization information from a
configuration file, not the inherited class.
This class contains several other properties. The first is the
Level property, which
gets and sets the current level of this object. The levels are defined in the
AppSpecificSwitchLevel enumeration. This class also contains a read-only property
for each element in the
AppSpecificSwitchLevel enumeration. These can be used to
query this object to determine whether its various levels are set.
See Also
See Recipes 8.1 and 8.2; see the “Switch Class” and “Trace and Debug Settings
Schema” topics in the MSDN documentation.
8.4 Compiling Blocks of Code Conditionally
Problem
Specific blocks of code will be used only in a certain build configuration for your
application. These blocks of code should not be compiled into other builds of the
application. You need a way to conditionally compile specific blocks of code based
on the type of build.
Solution
There are two devices for allowing or preventing code from being compiled. The first
is to use the C# preprocessor directives. The available preprocessor directives are:
#define
#undef
#if
#elif
#else
#endif
The #define and #undef preprocessor directives define and undefine symbols. These ...