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().InstancePerLifetimeScope(); builder.RegisterType().InstancePerLifetimeScope(); builder.RegisterType().InstancePerLifetimeScope(); builder.RegisterType().InstancePerLifetimeScope(); builder.RegisterType().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()) .WithParameter((pi, c) => pi.ParameterType == typeof(HRUnitOfWork), (pi, c) => c.Resolve()) .WithParameter((pi, c) => pi.ParameterType == typeof(LogUnitOfWork), (pi, c) => c.Resolve()) .WithParameter((pi, c) => pi.ParameterType == typeof(DataCenterUnitOfWork), (pi, c) => c.Resolve()) .WithParameter((pi, c) => pi.ParameterType == typeof(LYDataCenterUnitOfWork), (pi, c) => c.Resolve()) .PropertiesAutowired() .InstancePerLifetimeScope(); builder.RegisterAssemblyTypes(blAssembly) .Where(x => x.FullName.StartsWith("EMIS.DataLogic") && x.Name.EndsWith("DAL")) .AsSelf() .PropertiesAutowired() .InstancePerLifetimeScope(); } } }