/// <summary>
        /// 注入IKernel
        /// </summary>
        /// <param name="kernel"></param>
        public static void ConfigureDependencies(IKernel kernel)
        {
            var controllerFactory = new DependentInjectionControllerFactory(kernel);

            ControllerBuilder.Current.SetControllerFactory(controllerFactory);

            //预先绑顶Controlller,保证线程安全
            foreach (Type type in Assembly.GetExecutingAssembly().GetExportedTypes().Where(IsController))
                controllerFactory.Kernel.Bind(type).ToSelf();
        }
Пример #2
0
        /// <summary>
        /// 注入IKernel
        /// </summary>
        /// <param name="kernel"></param>
        public static void ConfigureDependencies(IKernel kernel)
        {
            var controllerFactory = new DependentInjectionControllerFactory(kernel);

            ControllerBuilder.Current.SetControllerFactory(controllerFactory);

            //预先绑顶Controlller,保证线程安全
            foreach (Type type in Assembly.GetExecutingAssembly().GetExportedTypes().Where(IsController))
            {
                controllerFactory.Kernel.Bind(type).ToSelf();
            }
        }