I have some UserControl
s in my c# project and use Structuremap 3
as my IoC container, when I want to access the UserControl
s I use following code:
var uc = new UserControlFactory().Create<MyUserControl>();
....
and this is UserControlFactory
code:
public class UserControlFactory:IUserControlFactory
{
public T Create<T>() where T : UserControl
{
return (T) ObjectFactory.GetInstance(typeof(T));
}
}
It work fine when I have some interface
s as my UserControl
s constructor parameters:
public class MyUserControl:UserControl
{
public MyUserControl(IMyInterface myInterface)
{
}
}
But now I want to pass an object through the UserControl
constructor:
public class MyUserControl:UserControl
{
public MyUserControl(IMyInterface myInterface,MyClass object1)
{
}
}
How can I do that?
You could try to pass parameter to the constructor as follows: