Пример #1
0
        protected virtual IClassLoader CreateClassLoader()
        {
            var loader = new SimpleClassLoader();

            //Assert.IsTrue(loader.IsDefault);
            return(loader);
        }
Пример #2
0
        /// <summary>
        /// 重置DI容器
        /// </summary>
        public static void Refresh()
        {
            if (ServiceLocator.Current != null)
            {
                ServiceLocator.Current.Dispose();
            }

            IKernel kernel = null;

            if (string.IsNullOrEmpty(ContainerType))
            {
                kernel = new Kernel();
            }
            else
            {
                var classLoader = new SimpleClassLoader();
                var type        = classLoader.Load(ContainerType);
                if (type != null)
                {
                    kernel = (IKernel)Activator.CreateInstance(type);
                }
            }

            ServiceLocator.Current  = kernel;
            ServiceRegistry.Current = kernel;
        }