Autofac中两个组件注册有什么区别?

时间:2014-01-04 17:52:57

标签: c# autofac asp.net-mvc-5 asp.net-web-api2

containerBuilder.RegisterInstance(new PostRepository()).As<IPostRepository>();

containerBuilder.RegisterType<PostRepository>().As<IPostRepository>();

我一直在尝试将Autofac集成到我的Web Api应用程序中。我一直在进行上面的组件注册。

这两种类型的注册是否相同,如果没有哪一种比另一种更好,以什么方式?

我已阅读的帖子

Autofac

Integrating with ASP.NET Web API

Dependency Injection in ASP.NET Web API using Autofac

Autofac and ASP.NET Web API System.Web.Http.Services.IDependencyResolver Integration

0 个答案:

没有答案