Beispiel #1
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)));
        }
Beispiel #2
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)));
        }