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); }
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); }
static void Main(string[] args) { var commandStringBuilder = new StringBuilder(); commandStringBuilder.AppendLine("5 5"); commandStringBuilder.AppendLine("1 2 N"); commandStringBuilder.AppendLine("LMLMLMLMM"); commandStringBuilder.AppendLine("3 3 E"); commandStringBuilder.Append("MMRMMRMRRM"); Console.WriteLine(commandStringBuilder.ToString()); var kernel = KernelFactory.CreateKernel(); var moveInvoker = kernel.Get <IMoveInvoker>(); List <ICommand> commands = null; try { commands = moveInvoker.InvokeAll(commandStringBuilder.ToString()); } catch (Exception e) { Console.WriteLine(e); Console.ReadLine(); Environment.Exit(0); } foreach (var item in commands) { try { item.Execute(); } catch (Exception e) { Console.WriteLine(e.Message); Console.ReadLine(); } } Console.ReadLine(); }