Reputation: 9
Can I do something like this:
Configs.Environment.Development;
I'm currently doing something like this:
Configs.Environment == "DEV";
I don't particularly care for the strings, but I don't know how to set "specific" properties or if it's possible.
Upvotes: 0
Views: 139
Reputation: 1351
Do you want the setting to take effect at compile time only or at runtime? Do you want your user to be able to select different settings after deployment?
If you want a compile time only setting, then a pre-processor directive is what you want.
If you want runtime settings, .NET has direct support for .config files and you can access the values in your code (and set them too) via the Settings.Default constructs.
VisualStudio has support for easily creating and maintaining these config files.
Upvotes: 0
Reputation: 58602
Yes.
public static class Configs{
public static class Environment{
public static readonly string Development="DEV";
}
}
But you probably want ENUMS, and use a factory to set your constants.
Upvotes: 0
Reputation: 53446
Are you talking about enums?
public enum Environment
{
Development,
Test,
Live
}
Configs.Environment = Environment.Development;
Upvotes: 3
Reputation: 41388
This sounds like the sort of thing that's better handled by a preprocessor directive:
#if debug
/* etc */
#elseif production
/* etc */
#endif
Upvotes: 1
Reputation: 10377
You could accomplish that by making Environment
an enumeration or making Development
a static readonly string.
Upvotes: 0