I have some UserControls in my c# project and use Structuremap 3 as my IoC container, when I want to access the UserControls 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 interfaces as my UserControls 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: