Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
 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));
 }
Exemplo n.º 4
0
        public ViewModelLocator()
        {
            if (!ViewModelBase.IsInDesignModeStatic)
            {
                IocContainer.Build();
            }

            var _ = IocContainer.BaseContainer;

            ServiceLocator.SetLocatorProvider(IocContainer.ServiceLocatorProvider);
        }
Exemplo n.º 5
0
        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();
        }
Exemplo n.º 6
0
 protected static void OneTimeSetup()
 {
     IocContainer.Build();
 }