I have a classic bootstrapping problem. I am trying to inject the TFS client libraries for version control into my application, but I need to load different versions of the client library in different situations: the TFS 2013 client libraries cannot connect to TFS 2005 or TFS 2008 servers, so I need to load an earlier version of the client libraries when connecting to these older versions of TFS. I have found that I can reliably determine the version of TFS that I am connecting to by requesting the BuildServerVersion
property from the IBuildServer
service.
Normally I would solve this problem using an Abstract Factory pattern and use an IoC container to load the appropriate factory implementation; however, normally the decision would be entirely the responsibility of the application. In my situation, the decision is based on the response from the TFS server, and, crucially, I have to load a version of the TFS client library to request that information from the TFS server in the first place.
What approaches can I consider to address this problem?