1234567891011121314151617181920212223242526272829303132333435 |
- 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<UnitOfWork>().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<UnitOfWork>())
- .PropertiesAutowired()
- .InstancePerLifetimeScope();
- builder.RegisterAssemblyTypes(blAssembly)
- .Where(x => x.FullName.StartsWith("EMISOnline.DataLogic") && x.Name.EndsWith("DAL"))
- .AsSelf()
- .PropertiesAutowired()
- .InstancePerLifetimeScope();
- }
- }
- }
|