You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
2.1 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. using Autofac;
  2. using Business.Account;
  3. using Business.Customer;
  4. using Business.ReferralReports;
  5. using Business.SendTransaction;
  6. using Repository.DAO.Account;
  7. using Repository.DAO.ReferralReports;
  8. using Repository.DAO.SendTransactionDao;
  9. using Repository.Repository.OnlineCustomerDao;
  10. namespace Business.Configuration
  11. {
  12. public class AutoFacContainer
  13. {
  14. public static IContainer DIContainer()
  15. {
  16. var builder = new ContainerBuilder();
  17. #region Services
  18. builder.RegisterType<AccountServices>().As<IAccountServices>();
  19. builder.RegisterType<ReferralReportsServices>().As<IReferralReportsServices>();
  20. builder.RegisterType<CustomerServices>().As<ICustomerServices>();
  21. builder.RegisterType<SendTransactionServices>().As<ISendTransactionServices>();
  22. #endregion Services
  23. #region Repos
  24. builder.RegisterType<AccountRepo>().As<IAccountRepo>();
  25. builder.RegisterType<ReferralReportsRepo>().As<IReferralReportsRepo>();
  26. builder.RegisterType<CustomerRepository>().As<ICustomerRepository>();
  27. builder.RegisterType<SendTransactionRepo>().As<ISendTransactionRepo>();
  28. //builder.RegisterType<AccountRepo>().As<IAccountRepo>();
  29. //builder.RegisterType<AccountRepo>().As<IAccountRepo>();
  30. //builder.RegisterType<AccountRepo>().As<IAccountRepo>();
  31. //builder.RegisterType<AccountRepo>().As<IAccountRepo>();
  32. //builder.RegisterType<AccountRepo>().As<IAccountRepo>();
  33. //builder.RegisterType<AccountRepo>().As<IAccountRepo>();
  34. //builder.RegisterType<AccountRepo>().As<IAccountRepo>();
  35. //builder.RegisterType<AccountRepo>().As<IAccountRepo>();
  36. #endregion Repos
  37. return builder.Build();
  38. }
  39. public static T Resolve<T>() where T : class
  40. {
  41. var scope = AutoFacContainer.DIContainer().BeginLifetimeScope();
  42. T a = scope.Resolve<T>();
  43. return a;
  44. }
  45. }
  46. }