Saturday, April 11, 2015

StructureMap polymorphism!

We have circled back to using polymorphism to tackle the problem described here and here but instead of using Activator.CreateInstance we are now using StructureMap like so:

For<IWebServiceVersion>().Use<WebServiceVersion13>().Named("Web Service 13");

 
 

...and like so:

public IContainer Container { get; set; }
public IWebServiceVersion WebServiceVersion(int version)
{
   return Container.GetInstance<IWebServiceVersion>("Web Service " + int);
}

No comments:

Post a Comment