using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Configuration; using System.Web; using System.Web.Mvc; using System.Data; using System.Data.Entity; using PalGain.Core; using PalGain.Core.Tasks; using Autofac; using Autofac.Integration.Mvc; using Autofac.Configuration; using sbcLabSystem.Data; using sbcLabSystem.Service.Account; using sbcLabSystem.Service.QC; using sbcLabSystem.Service.Task; namespace sbcLabSystem.Framework { public class DependencyRegistrar : IDependencyRegistrar { public void Register(ContainerBuilder builder, ITypeFinder typeFinder) { //HTTP context and other related stuff builder.Register(c => (new HttpContextWrapper(HttpContext.Current) as HttpContextBase)) .As() .InstancePerLifetimeScope(); builder.Register(c => c.Resolve().Request) .As() .InstancePerLifetimeScope(); builder.Register(c => c.Resolve().Response) .As() .InstancePerLifetimeScope(); builder.Register(c => c.Resolve().Server) .As() .InstancePerLifetimeScope(); builder.Register(c => c.Resolve().Session) .As() .InstancePerLifetimeScope(); //controllers builder.RegisterControllers(typeFinder.GetAssemblies().ToArray()); builder.Register(c => new sbcLabSystem.Data.DBContext.FreseniusDBContext()).InstancePerLifetimeScope(); builder.RegisterGeneric(typeof(EfRepository<>)).As(typeof(IRespository<>)).InstancePerLifetimeScope(); //cache manager builder.RegisterType().As().Named("nop_cache_static").SingleInstance(); //web helper builder.RegisterType().As().InstancePerLifetimeScope(); //services builder.RegisterType().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().InstancePerLifetimeScope(); } public int Order { get { return 0; } } } }