Beispiel #1
0
 private static IConfigurationKernel LoadKernel()
 {
     if (SingletonConfigurationKernel.IsInstance())
     {
         return(SingletonConfigurationKernel);
     }
     //var kernel = (IConfigurationKernel)ContainerFactory.Current(new ContextProviders.ScopeContext(null)).Resolve(typeof(IConfigurationKernel), KernelScope);
     //if (kernel.IsInstance()) return kernel;
     lock (Triowing)
     {
         if (SingletonConfigurationKernel.IsInstance())
         {
             return(SingletonConfigurationKernel);
         }
         var newKernel = KernelFactory.CreateKernel();
         // kernel = (IConfigurationKernel)ContainerFactory.Current(new ContextProviders.ScopeContext(ResolverKernel)).Resolve(typeof(IConfigurationKernel), KernelScope);
         //if (kernel.IsInstance()) return kernel;
         //ContainerFactory.Current(new ContextProviders.ScopeContext(ResolverKernel)).Bind(typeof(IConfigurationKernel), newKernel, KernelScope);
         if (SingletonConfigurationKernel == null && KernelScope == Scope.Singleton && OptimizedKernel)
         {
             SingletonConfigurationKernel = newKernel;
         }
     }
     return(SingletonConfigurationKernel);
 }
Beispiel #2
0
        private static IConfigurationKernel LoadKernel()
        {
            if (SingletonConfigurationKernel.IsInstance() && KernelScope == Scope.Singleton && OptimizedKernel)
            {
                return(SingletonConfigurationKernel);
            }
            var kernel = (IConfigurationKernel)ContainerFactory.Current.Resolve(typeof(IConfigurationKernel), KernelScope);

            if (kernel.IsInstance())
            {
                return(kernel);
            }
            lock (Triowing)
            {
                var newKernel = KernelFactory.CreateKernel();
                kernel = (IConfigurationKernel)ContainerFactory.Current.Resolve(typeof(IConfigurationKernel), KernelScope);
                if (kernel.IsInstance())
                {
                    return(kernel);
                }
                ContainerFactory.Current.Bind(typeof(IConfigurationKernel), newKernel, KernelScope);
                if (SingletonConfigurationKernel == null && KernelScope == Scope.Singleton && OptimizedKernel)
                {
                    SingletonConfigurationKernel = newKernel;
                }
            }
            return(kernel);
        }