有没有人对如何创建具有参数比使用依赖注入容器等控制器的任何code的例子吗?
Does anyone have any code examples on how to create controllers that have parameters other than using a Dependency Injection Container?
我看到很多的样品使用的容器,如StructureMap,但没有什么,如果你想通过自己的依赖类。
I see plenty of samples with using containers like StructureMap, but nothing if you wanted to pass in the dependency class yourself.
您可以用可怜的人的依赖注入:
You can use poor-man's dependency injection:
public ProductController() : this( new Foo() )
{
//the framework calls this
}
public ProductController(IFoo foo)
{
_foo = foo;
}