Пример #1
0
        static void Main(string[] args)
        {
            var kernel = new StandardKernel();
            kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => Bootstrapper.Container);

            var serverStatus = new ServerStatus();
            serverStatus.State = State.Instanciated;

            var logger = LogManager.GetLogger("server");

            kernel.Bind<ILog>().ToConstant(logger).InSingletonScope();

            kernel.Bind<ServerStatus>().ToConstant(serverStatus).InSingletonScope();

            kernel.Bind<ISessionFactory>().To<SessionFactory>().InSingletonScope();
            kernel.Bind<ITransactionProvider>().To<TransactionProvider>().InSingletonScope();
            kernel.Bind<ICacheClient>().To<MemoryCacheClient>().InSingletonScope();

            kernel.Load(new RepositoryModule(), new ModelModule(), new ConfigurationModule());

            Bootstrapper.Container = kernel;
            Bootstrapper.init();

            var actionLogic = kernel.Get<IActionLogic>();
            actionLogic.LoadServerActions();

            var serviceAppHost = new ServiceAppHost(kernel);
            serviceAppHost.Init();
            serviceAppHost.Start("http://*:7778/");

            serverStatus.State = State.Running;

            Console.WriteLine("Server up and running ...");

            Console.ReadLine();
            serviceAppHost.Stop();
            Console.WriteLine("Server shutting down ...");
        }
Пример #2
0
        protected override IKernel CreateKernel()
        {
            var kernel = new StandardKernel();
            kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => Bootstrapper.Container);
            //kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>();
            kernel.Bind<ServiceHost>().To<NinjectServiceHost>();

            var serverStatus = new ServerStatus();
            serverStatus.State = State.Instanciated;

            kernel.Bind<ServerStatus>().ToConstant(serverStatus).InSingletonScope();

            kernel.Bind<ISessionFactory>().To<SessionFactory>().InSingletonScope();
            kernel.Bind<ITransactionProvider>().To<TransactionProvider>().InSingletonScope();

            kernel.Load(new RepositoryModule(), new ModelModule(), new ConfigurationModule());

            Bootstrapper.Container = kernel;

            return kernel;
        }