I have a class in my project that contains a global configuration, as follows:
public class Config {
public const bool LOGGING_ENABLED = false;
}
Then I want to use this element to write a preprocessor directive, for example:
#if LOGGING_ENABLED
[Logging]
public class MyClass: ContextBoundObject
#else
public class MyClass
#endif
{
...
}
But it is clear that it LOGGING_ENABLEDwill appear as undefined, since in fact it does not refer to Config.LOGGING_ENABLED. Is there a way to refer to constant members in another class? I do not want to put #define LOGGING_ENABLEDat the beginning of each class file, which is detrimental to the whole purpose of this.
source
share