I have a WCF application which has the 2 default configurations, Debug and Release. I’ve also added two publishing profiles, Test and Live. throughout my code I make use of a class which has a constructor like so:
public MyClass(string server)
{
server = server.ToLower();
switch (server)
{
case "live":
LogonToLive();
break;
case "test":
LogonToTest();
break;
}
I then use which throughout my application like so:
using(var ax = new MyClass("test"))
{
// do stuff in my Test Environment
}
What I’d like to do is set up some variables in my web.config which will automatically replace MyClass("test") with the correct server based on which configuration/publish profile I have set. Is this possible?
You could use the trace constants of conditional compiling to determine the build configuration, and pull the desired value from a property in a ‘Configuration’ class, or something:
I think determining the publishing profile is a different kettle of fish, so to speak.