Autofac difference between Register and RegisterType

前端 未结 3 1485
野的像风
野的像风 2021-02-20 14:01

I have started to use Autofac following this tutorials: http://flexamusements.blogspot.com/2010/09/dependency-injection-part-3-making-our.html

Simple class with no pa

3条回答
  •  太阳男子
    2021-02-20 14:34

    You can't write that code because it doesn't make sense in C#.
    RegisterType is a generic method; generic methods must take types as generic parameters.

    You're trying to register a type with a custom way to create it (inyour case, a constructor parameter); the only way that C# supports to specify such a thing is a lambda expression (or other delegate).

提交回复
热议问题