/// <summary> /// Creates the kernel that will manage your application. /// </summary> /// <returns>The created kernel.</returns> private static IKernel CreateKernel() { var kernel = new ConcentratorKernel(); RegisterServices(kernel); ServiceLocator.SetLocatorProvider(() => new CommonServiceLocator.NinjectAdapter.NinjectServiceLocator(kernel)); return(kernel); }
public IKernel CreateKernel() { IKernel kernel = new ConcentratorKernel(new RequestScopeUnitOfWorkModule()); kernel.Load <CommonRepositoryModule>(); kernel.Load <ServiceModule>(); kernel.Load <ContextRequestScopeModule>(); kernel.Load <ManagementServiceModule>(); return(kernel); }
/// <summary> /// Initializes the Concentrator Kernel. /// </summary> public static void Initialize() { lock (GlobalLock) { if (!IsInitialized) { Kernel = new ConcentratorKernel(new ServiceModule(), new ThreadScopeUnitOfWorkModule(), new UnsecuredRepositoryModule()); ServiceLocator.SetLocatorProvider(() => new NinjectServiceLocator(Kernel)); Client.User = new ConcentratorPrincipal(new ConcentratorIdentity(new UserIdentityModel(1))); IsInitialized = true; } } }
static void Main(string[] args) { XmlConfigurator.Configure(); var serviceName = ConfigurationManager.AppSettings["ServiceName"].IfNullOrEmpty("Concentrator Service Host"); AppDomain.CurrentDomain.AssemblyResolve += (sender, arguments) => { var pluginDirectory = ConfigurationManager.AppSettings["PluginPath"]; if (!Directory.Exists(pluginDirectory)) { throw new IOException(String.Format("'{0}' does not exist.", pluginDirectory)); } var assemblyName = new AssemblyName(arguments.Name); var fullName = Path.Combine(pluginDirectory, assemblyName.Name + ".dll"); if (!File.Exists(fullName)) { throw new IOException(String.Format("'{0}' does not exist.", fullName)); } return(Assembly.LoadFile(fullName)); }; #if DEBUG IKernel kernel = new ConcentratorKernel(new ManagementServiceModule(), new ContextThreadScopeModule(), new ThreadScopeUnitOfWorkModule(), new UnsecuredRepositoryModule(), new ServiceModule()); var locator = new NinjectServiceLocator(kernel); ServiceLocator.SetLocatorProvider(() => locator); if (args.Length > 0) { ServiceLayer.Start(args[0].Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToArray().Select(c => int.Parse(c)).ToArray()); } else { ServiceLayer.Start(); } Console.ReadLine(); ServiceLayer.Stop(); #else RunConfiguration cfg = RunnerConfigurator.New(x => { IKernel kernel = new ConcentratorKernel(new ManagementServiceModule(), new ContextThreadScopeModule(), new ThreadScopeUnitOfWorkModule(), new UnsecuredRepositoryModule(), new ServiceModule()); var locator = new NinjectServiceLocator(kernel); ServiceLocator.SetLocatorProvider(() => locator); x.ConfigureService <ServiceLayer>(s => { s.Named("tc"); s.HowToBuildService(name => ServiceLayer.Instance); s.WhenStarted(tc => ServiceLayer.Start()); s.WhenStopped(tc => ServiceLayer.Stop()); }); x.SetDescription("Concentrator Host Process for running plugins"); x.SetDisplayName(serviceName); //staging x.SetServiceName(serviceName); //staging x.RunAsLocalSystem(); // } }); Runner.Host(cfg, args); #endif }