Exemplo n.º 1
0
        protected override void Load(ContainerBuilder builder)
        {
            //Services
            builder.RegisterType <DataService>().As <IDataService>().InstancePerRequest();

            //AutoMapper
            var mapper = new MapperConfig().GetMapper();

            builder.RegisterInstance(mapper);

            base.Load(builder);
        }
Exemplo n.º 2
0
        public override void Load()
        {
            //Services
            Bind <IDataService>().To <DataService>();
            Bind <IAccessService>().To <AccessService>();
            Bind <IStaffService>().To <StaffService>();
            Bind <IValidationService>().To <ValidationService>();

            //Automapper
            var mapperConfiguration = MapperConfig.CreateConfiguration();

            Bind <MapperConfiguration>().ToConstant(mapperConfiguration).InSingletonScope();
            Bind <IMapper>().ToMethod(ctx => new Mapper(mapperConfiguration, type => ctx.Kernel.Get(type)));
        }
Exemplo n.º 3
0
        public override void Load()
        {
            //Services
            Bind <IDataService>().To <DataService>();
            Bind <IAuthService>().To <AuthService>();

            //Automapper
            var mapperConfiguration = MapperConfig.CreateConfiguration();

            Bind <MapperConfiguration>().ToConstant(mapperConfiguration).InSingletonScope();

            // This teaches Ninject how to create automapper instances say if for instance
            // MyResolver has a constructor with a parameter that needs to be injected
            Bind <IMapper>().ToMethod(ctx =>
                                      new Mapper(mapperConfiguration, type => ctx.Kernel.Get(type)));
        }