示例#1
0
        public static void Bootstrap(HttpConfiguration config)
        {
            var mapperConfig = MapperConfig.Configure();

            var builder = new ContainerBuilder();

            builder.RegisterApiControllers(Assembly.GetExecutingAssembly());

            // Dummy implementation
            //builder.RegisterType<DummyEventRepo>().As<IEventRepository>().InstancePerLifetimeScope();

            // Real implementation
            builder.RegisterType <EventRepository>().As <IEventRepository>().InstancePerLifetimeScope();
            builder.RegisterType <MeasurementRepository>().As <IMeasurementRepository>().InstancePerLifetimeScope();
            builder.RegisterType <ChatMessageRepository>().As <IChatMessageRepository>().InstancePerLifetimeScope();
            builder.RegisterType <TellerContext>().InstancePerLifetimeScope();

            builder.RegisterInstance(mapperConfig).As <MapperConfiguration>();

            var container = builder.Build();

            config.DependencyResolver = new AutofacWebApiDependencyResolver(container);
        }
示例#2
0
 protected void Application_Start()
 {
     GlobalConfiguration.Configure(WebApiConfig.Register);
     GlobalConfiguration.Configure(IocConfig.Bootstrap);
     MapperConfig.Configure();
 }