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