protected void Application_Start() { AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); //api registrations IocContainer.ContainerBuilder.RegisterApiControllers(Assembly.GetExecutingAssembly()); IocContainer.ContainerBuilder.RegisterWebApiFilterProvider(GlobalConfiguration.Configuration); IocContainer.ContainerBuilder.RegisterWebApiModelBinderProvider(); //component registrations Repos.Ioc.IocRegistration.Register(); Services.Ioc.IocRegistration.Register(); //IocContainer.RegisterInstance<IConnection>(new Connection //{ // Name = ConfigurationManager.ConnectionStrings["Default"].Name, // ConnectionString = ConfigurationManager.ConnectionStrings["Default"].ConnectionString //}); IocContainer.RegisterType <MoqRepo, IRepoService>(); //build ioc container IocContainer.Build(); //assign autofac dependency resolver GlobalConfiguration.Configuration.DependencyResolver = new AutofacWebApiDependencyResolver(IocContainer.Container); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); UnityConfig.RegisterComponents(); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); //set api endpoint ApiEndpoint.DefaultApi = ConfigurationManager.AppSettings["ApiEndpoint"]; //implement ioc container //controller registrations IocContainer.ContainerBuilder.RegisterControllers(typeof(WebApiApplication).Assembly); //component registrations IocRegistration.Register(); //build ioc container IocContainer.Build(); //assign autofac dependency resolver DependencyResolver.SetResolver(new AutofacDependencyResolver(IocContainer.Container)); }
public static IServiceProvider InitIoC(IServiceCollection services) { IocContainer.Register(typeof(DapperRepositoryBase <>).Assembly, "QueryRepository"); IocContainer.Register(typeof(EntityFrameworkRepositoryBase <>).Assembly, "CommandRepository"); //IocContainer.Register(typeof(DapperRepositoryBase<>), typeof(IDapperQueryRepository<>)); //IocContainer.Register(typeof(EntityFrameworkRepositoryBase<>), typeof(IEntityFrameworkCommandRepository<>)); IocContainer.Register(typeof(BaseService).Assembly, "Service"); return(IocContainer.Build(services)); }
public ViewModelLocator() { if (!ViewModelBase.IsInDesignModeStatic) { IocContainer.Build(); } var _ = IocContainer.BaseContainer; ServiceLocator.SetLocatorProvider(IocContainer.ServiceLocatorProvider); }
public TestPriceRepo() { //default registerations RealmdigitalInterview.Repos.Ioc.IocRegistration.Register(); //mog registration overides //IocContainer.RegisterInstance<IConnection>(new Connection //{ // Name = ConfigurationManager.ConnectionStrings["Default"].Name, // ConnectionString = ConfigurationManager.ConnectionStrings["Default"].ConnectionString //}); IocContainer.RegisterType <MoqRepo, IRepoService>(); IocContainer.Build(); }
protected static void OneTimeSetup() { IocContainer.Build(); }