0

I'm sectioning off pieces of a solutions into individual solutions and integrating them into an Atlassian Bamboo build/deploy environment. I have a site, a WCF with Windows Workflow Foundation, and a library containing all the classes that are shared. All is written in C# btw.

One thing inside the library is a class that interfaces with a Magento (php based) SOAP interface. Basically it just provides me with a handler for all of the SOAP Exceptions that Magento spits back to me. It uses SOAP Exceptions as valid, but bad results... Example "Product X does not exist". etc.

It could be ANY SOAP interface though. MEAT AND POTATOS:

I have a development and production Magento machine, and I have two pretty much identical soap interfaces.. www.mysite.com/soap/etc and dev.mysite.com/soap/etc exposed by these two machines. Each is loaded as a web reference in the library, and for a long time I was using a compile time #if DEBUG constant to switch between two different "Using" statements. Whether I picked debug or release, it would choose the correct reference. Here is the code:

#if DEBUG
    using NKI.Library.MagentoDev;
#else
    using NKI.Library.MagentoProd;
#endif

Now, I need to be able to specify this 'pick' later, after the library has been compiled into a DLL.. (btw, don't get on my case about hard coding a url into the dll :)

CarComp
  • 1,929
  • 1
  • 21
  • 47

1 Answers1

1

The preprocessor is obviously a compile-time directive as is using. You can't change what using does after compilation for obvious reasons.

That said, if both MagentoDev and MagentoProd derive from the same common base-class, then there's nothing stopping you have a configuration file where a setting is read in and the code uses the appropriate interface.

Moo-Juice
  • 38,257
  • 10
  • 78
  • 128