I have an interface, let's call it ILocateLogFile
, with a standard implementation for dev/beta/production servers, and one that only works in the local development environment. I can't seem to think of a nice clean way to decide (preferably at compile time, but runtime would be fine) if I'm running locally or on a server. This is a WCF application hosted on IIS, if that matters.
The best I've come up with is to use a compiler symbol, something like:
ILocateLogFile locateLogFile;
#if DEBUG
locateLogFile = new DevSandboxLogFileLocator();
#else
locateLogFile = new LogFileLocator();
#endif
The problem is, compile symbols get set by the build, which I don't control, and I want to be certain. Isn't there some automagical way to check for the presence of Visual Studio? Or at least to check for Cassini rather than IIS?