/// <summary>
        /// When implemented in a derived class, executes when a Start command
        /// is sent to the service by the Service Control Manager (SCM) or when
        /// the operating system starts (for a service that starts
        /// automatically). Specifies actions to take when the service starts.
        /// </summary>
        /// <param name="args">Data passed by the start command.</param>
        protected override void OnStart(string[] args)
        {
            var timeServiceComfiguration = NinjectWcfConfiguration.Create<TimeService, NinjectServiceSelfHostFactory>();
            var timeWebServiceComfiguration = NinjectWcfConfiguration.Create<TimeWebService, NinjectWebServiceSelfHostFactory>();

            this.selfHost = new NinjectSelfHostBootstrapper(
                CreateKernel, 
                timeServiceComfiguration,
                timeWebServiceComfiguration);
            this.selfHost.Start();
        }
Пример #2
0
        /// <summary>
        /// The application main method.
        /// </summary>
        /// <param name="args">The arguments.</param>
        public static void Main(string[] args)
        {
            var webApiConfiguration = new HttpSelfHostConfiguration("http://localhost:8080");
            webApiConfiguration.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "{controller}/{id}",
                defaults: new { id = RouteParameter.Optional, controller = "values" });

            using (var selfHost = new NinjectSelfHostBootstrapper(CreateKernel, webApiConfiguration))
            {
                selfHost.Start();
                Console.WriteLine("Press Enter to quit.");
                Console.ReadLine();
            }
        }
Пример #3
0
        static void Main(string[] args)
        {
            // Registry kernel
            IKernel kernel = new StandardKernel(new ServiceModule());

            // Create service config
            NinjectWcfConfiguration roomServiceConfig = NinjectWcfConfiguration.Create<RoomService, NinjectServiceSelfHostFactory>();
            NinjectWcfConfiguration roomTypeServiceConfig = NinjectWcfConfiguration.Create<RoomTypeService, NinjectServiceSelfHostFactory>();
            NinjectWcfConfiguration roomAssetServiceConfig = NinjectWcfConfiguration.Create<RoomAssetService, NinjectServiceSelfHostFactory>();
            NinjectWcfConfiguration roomCalenderServiceConfig = NinjectWcfConfiguration.Create<RoomCalenderService, NinjectServiceSelfHostFactory>();
            NinjectWcfConfiguration roomCalendarStatusServiceConfig = NinjectWcfConfiguration.Create<RoomCalendarStatusService, NinjectServiceSelfHostFactory>();

            NinjectWcfConfiguration staffServiceConfig = NinjectWcfConfiguration.Create<StaffService, NinjectServiceSelfHostFactory>();
            NinjectWcfConfiguration staffTypeServiceConfig = NinjectWcfConfiguration.Create<StaffTypeService, NinjectServiceSelfHostFactory>();

            NinjectWcfConfiguration assetServiceConfig = NinjectWcfConfiguration.Create<AssetService, NinjectServiceSelfHostFactory>();
            NinjectWcfConfiguration roomAssetHistoryServiceConfig = NinjectWcfConfiguration.Create<RoomAssetHistoryService, NinjectServiceSelfHostFactory>();
            NinjectWcfConfiguration roomAssetHistoryTypeServiceConfig = NinjectWcfConfiguration.Create<RoomAssetHistoryTypeService, NinjectServiceSelfHostFactory>();

            using (var selfHost = new NinjectSelfHostBootstrapper(() => kernel,
                roomServiceConfig,
                roomTypeServiceConfig,
                roomAssetServiceConfig,
                roomCalenderServiceConfig,
                roomCalendarStatusServiceConfig,
                staffServiceConfig,
                staffTypeServiceConfig,
                assetServiceConfig,
                roomAssetHistoryServiceConfig,
                roomAssetHistoryTypeServiceConfig))
            {
                selfHost.Start();
                Console.Write("All Services Started. Press \"Enter\" to stop thems...");
                Console.ReadLine();
            }
        }