12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Reflection;
- using System.Xml.Linq;
- using Autofac;
- using EMIS.DataLogic;
- using EMIS.Utility;
- using Bowin.Common.XML;
- namespace EMIS.CommonLogic
- {
- public class DALModule : Autofac.Module
- {
- protected override void Load(ContainerBuilder builder)
- {
- builder.RegisterType<UnitOfWork>().InstancePerLifetimeScope();
- builder.RegisterType<HRUnitOfWork>().InstancePerLifetimeScope();
- builder.RegisterType<LogUnitOfWork>().InstancePerLifetimeScope();
- builder.RegisterType<DataCenterUnitOfWork>().InstancePerLifetimeScope();
- builder.RegisterType<LYDataCenterUnitOfWork>().InstancePerLifetimeScope();
- var blAssembly = typeof(EMIS.DataLogic.UnitOfWork).Assembly;
- builder.RegisterAssemblyTypes(blAssembly)
- .Where(x => x.Name.EndsWith("Repository") && x.BaseType.GetGenericArguments()[0].FullName.StartsWith("EMIS.Entities"))
- .AsSelf()
- .WithParameter((pi, c) => pi.ParameterType == typeof(UnitOfWork),
- (pi, c) => c.Resolve<UnitOfWork>())
- .WithParameter((pi, c) => pi.ParameterType == typeof(HRUnitOfWork),
- (pi, c) => c.Resolve<HRUnitOfWork>())
- .WithParameter((pi, c) => pi.ParameterType == typeof(LogUnitOfWork),
- (pi, c) => c.Resolve<LogUnitOfWork>())
- .WithParameter((pi, c) => pi.ParameterType == typeof(DataCenterUnitOfWork),
- (pi, c) => c.Resolve<DataCenterUnitOfWork>())
- .WithParameter((pi, c) => pi.ParameterType == typeof(LYDataCenterUnitOfWork),
- (pi, c) => c.Resolve<LYDataCenterUnitOfWork>())
- .PropertiesAutowired()
- .InstancePerLifetimeScope();
- builder.RegisterAssemblyTypes(blAssembly)
- .Where(x => x.FullName.StartsWith("EMIS.DataLogic") && x.Name.EndsWith("DAL"))
- .AsSelf()
- .PropertiesAutowired()
- .InstancePerLifetimeScope();
- }
- }
- }
|