I am trying to create an interface wrapper for my IOC container so I do not have to have a dependency on a particular one. My problem is that some of the service classes I have take in a companyID which is a string. I want to make generic interface methods like
T Resolve<T>()
where T is the service interface.
Right now I use StructureMap behind the scenes and know if the concrete constructor takes in the companyID so I will do something like this:
ObjectFactory.With("companyid").EqualTo("someCompanyID").GetInstance<ICompanyService>();
I wrap this sort of call in an interface method:
ICompanyService GetCompanyService(string companyID)
The way I have it now, the application has to initialize StructureMaps config and the concrete class, that passes back the services, has to know a lot about the constructors. I would like for that not to happen and to make the wrapper generic. Is there a nice way, without having to add companyID
to each method on the interface?