public static void Init(ContainerBuilder containerBuilder) { containerBuilder.Register( c => new MapperConfiguration(cfg => { cfg.AddProfile(new DtoToEntityProfile()); cfg.AddProfile(new EntityToDtoProfile()); })) .AsSelf() .SingleInstance(); containerBuilder.Register( c => c.Resolve <MapperConfiguration>().CreateMapper(c.Resolve)) .As <IMapper>() .InstancePerLifetimeScope(); containerBuilder.RegisterType <SqlVacationService>().As <ISqlVacationService>(); containerBuilder.RegisterType <ApiVacationService>().As <IApiVacationService>(); containerBuilder.RegisterType <CommonApiRepository>().As <IApiRepository>(); containerBuilder.RegisterGeneric(typeof(CommonSqlRepository <>)) .As(typeof(ISqlRepository <>)) .InstancePerDependency(); AutoMapperCoreConfiguration.Configure(); }
public override void Initialize() { base.Initialize(); AutoMapperCoreConfiguration.Configure(); Mvx.RegisterSingleton <IMvxAppStart>(new CustomAppStart()); Mvx.RegisterType <ISqlVacationService, SqlVacationService>(); Mvx.RegisterType <IApiVacationService, ApiVacationService>(); Mvx.RegisterType <IApiRepository, CommonApiRepository>(); Mvx.RegisterType <IUserRepository, UserRepository>(); Mvx.RegisterType <IAccountService, AccountService>(); }
public override void Load() { AutoMapperCoreConfiguration.Configure(); Bind <IMapper>().ToConstant(AutoMapper.Mapper.Instance).InSingletonScope(); Bind <ApplicationDbContext>().ToSelf().InRequestScope(); Bind <IBuyerRepository>().To <BuyerRepository>().InRequestScope(); Bind <ICategoryRepository>().To <CategoryRepository>().InRequestScope(); Bind <IImageRepository>().To <ImageRepository>().InRequestScope(); Bind <IOrderRepository>().To <OrderRepository>().InRequestScope(); Bind <IProductRepository>().To <ProductRepository>().InRequestScope(); Bind <ISellerRepository>().To <SellerRepository>().InRequestScope(); Bind <IAuctionRepository>().To <AuctionRepository>().InRequestScope(); Bind <IShoppingCartRepository>().To <ShoppingCartRepository>().InRequestScope(); Bind <IUserRepository>().To <UserRepository>().InRequestScope(); if (Kernel != null) { Bind <ApplicationUserManager>() .ToMethod( context => new ApplicationUserManager( new UserStore <User>(Kernel.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext))) .InRequestScope(); } }