/// <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 service = KernelContainer.Kernel.Get<ITimeService>(); _host = new NinjectServiceHost( service ); _host.AddServiceEndpoint( typeof (ITimeService), new NetTcpBinding(), "net.tcp://localhost/TimeService" ); _host.Open(); }
/// <summary> /// Initializes a new instance of the <see cref="WindowsTimeService"/> class. /// </summary> /// <param name="timeServiceHost">The time service host.</param> /// <param name="timeWebServiceHost">The time web service host.</param> public WindowsTimeService(NinjectServiceHost<TimeService> timeServiceHost, NinjectWebServiceHost<TimeWebService> timeWebServiceHost) { this.InitializeComponent(); this.timeServiceHost = timeServiceHost; this.timeWebServiceHost = timeWebServiceHost; }
/// <summary> /// When implemented in a derived class, executes when a Stop command is /// sent to the service by the Service Control Manager (SCM). Specifies /// actions to take when a service stops running. /// </summary> protected override void OnStop() { if ( _host != null ) { _host.Close(); _host = null; } }
public static void Main(string[] args) { var modules = new INinjectModule[] { new DomasNinjectModule() }; KernelContainer.Kernel = new StandardKernel(modules); var binding = new BasicHttpBinding(); var address = new Uri("http://127.0.0.1:8888"); var host = new NinjectServiceHost(typeof(DomasService)); host.AddServiceEndpoint(typeof(IDomasService), binding, address); host.Open(); Console.WriteLine("Press enter to stop.."); Console.ReadLine(); host.Close(); }