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<HttpContextBase>()
|
.InstancePerLifetimeScope();
|
builder.Register(c => c.Resolve<HttpContextBase>().Request)
|
.As<HttpRequestBase>()
|
.InstancePerLifetimeScope();
|
builder.Register(c => c.Resolve<HttpContextBase>().Response)
|
.As<HttpResponseBase>()
|
.InstancePerLifetimeScope();
|
builder.Register(c => c.Resolve<HttpContextBase>().Server)
|
.As<HttpServerUtilityBase>()
|
.InstancePerLifetimeScope();
|
builder.Register(c => c.Resolve<HttpContextBase>().Session)
|
.As<HttpSessionStateBase>()
|
.InstancePerLifetimeScope();
|
|
//controllers
|
builder.RegisterControllers(typeFinder.GetAssemblies().ToArray());
|
builder.Register<IDbContext>(c =>
|
new sbcLabSystem.Data.DBContext.FreseniusDBContext()).InstancePerLifetimeScope();
|
builder.RegisterGeneric(typeof(EfRepository<>)).As(typeof(IRespository<>)).InstancePerLifetimeScope();
|
//cache manager
|
builder.RegisterType<MemoryCacheManager>().As<ICacheManager>().Named<ICacheManager>("nop_cache_static").SingleInstance();
|
//web helper
|
builder.RegisterType<WebHelper>().As<IWebHelper>().InstancePerLifetimeScope();
|
//services
|
builder.RegisterType<AccountService>().InstancePerLifetimeScope();
|
builder.RegisterType<ScheduleTaskService>().As<IScheduleTaskService>().InstancePerLifetimeScope();
|
builder.RegisterType<QCService>().InstancePerLifetimeScope();
|
}
|
|
public int Order
|
{
|
get { return 0; }
|
}
|
}
|
}
|