Beispiel #1
0
        static ServiceKernel()
        {
            var r = new CustomDependencyResolver();

            // ReSharper disable once CoVariantArrayConversion
            Kernel = new StandardKernel(r.GetModules());
        }
        public void GetCustomModules()
        {
            var customResolver = new CustomDependencyResolver();
            var modules        = customResolver.GetModules();

            Assert.That(modules.Count(), Is.GreaterThan(0));
        }
Beispiel #3
0
        static ServiceKernel()
        {
            var r = new CustomDependencyResolver();

            // ReSharper disable once CoVariantArrayConversion
            Kernel = new StandardKernel(r.GetModules());
        }
Beispiel #4
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddControllers();
     CustomDependencyResolver.InjectDependencies(services, Configuration.GetConnectionString("AppConnectionString"));
     //services.AddScoped<IUnitOfWork, UnitOfWork>();
     //services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("AppConnectionString")));
     //services.AddScoped<ICustomerService, CustomerService>();
 }
Beispiel #5
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            CustomDependencyResolver.Bind <IRepository <City>, IoRepository>();
            DependencyResolver.SetResolver(new CustomDependencyResolver());
        }
Beispiel #6
0
        public static void Bootstrap()
        {
            var bootstrapper = new Bootstrapper();

            bootstrapper.Run();

            var dependencyResolver = new CustomDependencyResolver(IoC.CurrentContainer);

            DependencyResolver.SetResolver(dependencyResolver);
            GlobalConfiguration.Configuration.DependencyResolver = dependencyResolver;
        }
Beispiel #7
0
        /// <summary>
        ///     Bootstraps this instance.
        /// </summary>
        public static void Bootstrap()
        {
            var bootstrapper = new Bootstrapper();

            bootstrapper.Run();

            var dependencyResolver = new CustomDependencyResolver(IoC.CurrentContainer);

            DependencyResolver.SetResolver(dependencyResolver);
            ControllerBuilder.Current.SetControllerFactory(typeof(ExposedTypeCacheControllerFactory));
            GlobalConfiguration.Configuration.DependencyResolver = dependencyResolver;
        }
        public void GetCustomModules()
        {
            IDependencyResolver <NinjectModule> customResolver = new CustomDependencyResolver();

            var modules = customResolver.GetModules();

            Assert.That(modules.Count, Is.GreaterThan(0));
            Assert.That(modules, Is.TypeOf(typeof(NinjectModule[])));

            foreach (var m in modules)
            {
                Assert.That(m.GetType().BaseType, Is.EqualTo(typeof(NinjectModule)));
            }
        }
        public void GetCustomModules()
        {
            IDependencyResolver<NinjectModule> customResolver = new CustomDependencyResolver();

            var modules = customResolver.GetModules();

            Assert.That(modules.Count, Is.GreaterThan(0));
            Assert.That(modules, Is.TypeOf(typeof(NinjectModule[])));

            foreach (var m in modules)
            {
                Assert.That(m.GetType().BaseType, Is.EqualTo(typeof(NinjectModule)));
            }
        }
Beispiel #10
0
        public static void Register(HttpConfiguration config)
        {
            var services = new ServiceCollection();

            services.AddControllersAsServices(GetControllers());
            var dbPath = HostingEnvironment.MapPath(@"~/bin/DataBase/geobase.dat");
            var client = new GeoDataBaseClient(dbPath);

            client.Init();
            services.AddSingleton <IGeoDataBaseQuery>(new GeoDataBaseQuery(client));
            var resolver = new CustomDependencyResolver(services.BuildServiceProvider());

            config.DependencyResolver = resolver;
        }
Beispiel #11
0
        /// <summary>
        /// Creates the kernel that will manage your application.
        /// </summary>
        /// <returns>The created kernel.</returns>
        private static IKernel CreateKernel()
        {
            var dependencyResolver = new CustomDependencyResolver();
            var modules            = dependencyResolver.GetModules();

            var kernel = new StandardKernel(modules);

            try
            {
                kernel.Bind <Func <IKernel> >().ToMethod(ctx => () => new Bootstrapper().Kernel);
                kernel.Bind <IHttpModule>().To <HttpApplicationInitializationHttpModule>();

                RegisterServices(kernel);
                return(kernel);
            }
            catch
            {
                kernel.Dispose();
                throw;
            }
        }
Beispiel #12
0
        /// <summary>
        /// Creates the kernel that will manage your application.
        /// </summary>
        /// <returns>The created kernel.</returns>
        private static IKernel CreateKernel()
        {
            var modules   = new CustomDependencyResolver();
            var newKernal = modules.GetModules();

            var kernel = new StandardKernel(newKernal);

            GlobalHost.DependencyResolver.Register(typeof(IHubActivator), () => new HubActivator(kernel));

            try
            {
                kernel.Bind <Func <IKernel> >().ToMethod(ctx => () => new Bootstrapper().Kernel);
                kernel.Bind <IHttpModule>().To <HttpApplicationInitializationHttpModule>();

                Kernel = kernel;
                return(kernel);
            }
            catch
            {
                kernel.Dispose();
                throw;
            }
        }
Beispiel #13
0
        /// <summary>
        /// Creates the kernel that will manage your application.
        /// </summary>
        /// <returns>The created kernel.</returns>
        private static IKernel CreateKernel()
        {
            var modules = new CustomDependencyResolver();
            var newKernal = modules.GetModules();

            var kernel = new StandardKernel(newKernal);

            GlobalHost.DependencyResolver.Register(typeof(IHubActivator), () => new HubActivator(kernel));

            try
            {
                kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => new Bootstrapper().Kernel);
                kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>();

                Kernel = kernel;
                return kernel;
            }
            catch
            {
                kernel.Dispose();
                throw;
            }
        }