So say that I have type that takes some parameters in the constructor, like this:
public MyType(IComObject wrapper,string table) {}
now IComObject is a wrapper over a two different COM objects. All(90%) of my types have to use IComObject, so in good DI fashion (to allow for testing) I am passing IComObject into every type that needs it.
The main problem is that when someone goes to use my COM wrapper library that have to pass an instance of IComObject into everything they do which makes the code a little bit hard to manage and maintain.
I was wondering if I should use a IoC container or a global variable that the user can set so that they don't have to pass the IComOject instance around. Example:
public MyType(string table)
: this(IoC.Resolve<IComObject>,table) {}
or
public MyType(string table)
: this(StaticClass.ComInstance,table) {}
So that the user can do this:
//Set up Ioc container
COMObject object = new COMObject();
Ioc.Register(typeof(IComObject),object);
MyType mytype = new MyType("test.tab");
or
COMObject object = new COMObject();
StaticClass.ComInstance = object;
MyType mytype = new MyType("test.tab");
What do you think I should do in this situation?