Beispiel #1
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);


            AutoMapperWrapper.Init();

            var container = new Container();

            container.Options.DefaultScopedLifestyle = new WebApiRequestLifestyle();

            var registration = Lifestyle.Scoped.CreateRegistration <CommandQueryFactory>(container);


            container.AddRegistration(typeof(IQueryFactory), registration);
            container.AddRegistration(typeof(ICommandFactory), registration);

            // This is an extension method from the integration package.
            container.RegisterWebApiControllers(GlobalConfiguration.Configuration);

            container.Verify();

            GlobalConfiguration.Configuration.DependencyResolver =
                new SimpleInjectorWebApiDependencyResolver(container);
        }
Beispiel #2
0
        // This method gets called by the runtime. Use this method to add services to the container
        public void ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            services.AddApplicationInsightsTelemetry(Configuration);

            services.AddMvc();

            AutoMapperWrapper.Init();
            //services.AddScoped<CommandQueryFactory>();
            services.AddScoped <IQueryFactory, CommandQueryFactory>();
            services.AddScoped <ICommandFactory, CommandQueryFactory>();
        }