static void Main(string[] args) { LogFactory.Assign(new ConsoleLogFactory()); ServiceHostInfo info = new ServiceHostInfo(); info.Name = ConfigurationMaster.Get(ServiceConfiguration.DefaultServiceConfigurationName); info.Address = Dns.GetHostName(); info.Port = int.Parse(ConfigurationMaster.Get(ServiceConfiguration.DefaultServicePortConfigurationName)); info.Binding = new NetTcpBinding(ServiceConfiguration.DefaultNetTcpBindingName); info.Contract = typeof(IDeviceConnectorService); info.Service = typeof(DeviceConnectorService); Console.WriteLine(string.Format(@"Service is starting on [{0}]", info.ToString())); ManagedServiceHostActivator <IDeviceConnectorService> activator = new ManagedServiceHostActivator <IDeviceConnectorService>(info); activator.Start(); Console.WriteLine(string.Format(@"Service address [{0}]", activator.ServiceHost.Description.Endpoints.First().Address)); Console.WriteLine(); Console.WriteLine("Press any key to close service."); Console.ReadKey(); activator.Stop(); }
static void Main(string[] args) { LogFactory.Assign(new ConsoleLogFactory()); ServiceHostInfo info = new ServiceHostInfo(); info.Name = ConfigurationMaster.Get(ServiceConfiguration.DefaultServiceConfigurationName); info.Address = Dns.GetHostName(); info.Port = int.Parse(ConfigurationMaster.Get(ServiceConfiguration.DefaultServicePortConfigurationName)); info.Binding = new NetTcpBinding(ServiceConfiguration.DefaultNetTcpBindingName); info.Contract = typeof(IServiceDiscoveryService); info.Service = typeof(ServiceDiscoveryService); Console.WriteLine(string.Format(@"Service is starting on [{0}]", info.ToString())); ManagedServiceHostActivator<IServiceDiscoveryService> activator = new ManagedServiceHostActivator<IServiceDiscoveryService>(info); activator.Start(); Console.WriteLine(string.Format(@"Service address [{0}]", activator.ServiceHost.Description.Endpoints.First().Address)); Console.WriteLine(); Console.WriteLine("Press any key to close service."); Console.ReadKey(); activator.Stop(); }
static void Main(string[] args) { LogFactory.Assign(new ConsoleLogFactory()); ServiceProvider.Bootstrap(); ServiceHostInfo info = new ServiceHostInfo(); info.Name = ConfigurationMaster.Get(ServiceConfiguration.DefaultServiceConfigurationName); info.Address = Dns.GetHostName(); info.Port = int.Parse(ConfigurationMaster.Get(ServiceConfiguration.DefaultServicePortConfigurationName)); info.Binding = new NetTcpBinding(ServiceConfiguration.DefaultNetTcpBindingName); info.Contract = typeof(IDeviceProfileService); info.Service = typeof(DeviceProfileService); Console.WriteLine(string.Format(@"Service is starting on [{0}]", info.ToString())); ManagedServiceHostActivator <IDeviceProfileService> activator = new ManagedServiceHostActivator <IDeviceProfileService>(info); activator.Start(); Console.WriteLine(string.Format(@"Service address [{0}]", activator.ServiceHost.Description.Endpoints.First().Address)); string serverName = ConfigurationMaster.Get(@"HttpServerName"); string httpServerName = serverName + " HTTP Server"; int httpBindingPort = int.Parse(ConfigurationMaster.Get(@"HttpServerPort")); Server server = null; server = new Server(httpServerName); server.Add(HttpListenerFactory.Create(IPAddress.Any, httpBindingPort)); server.Add(new CameraListModule()); server.Add(new CameraModule()); server.Add(new CameraThumbnailModule()); FileModule fileModule = new FileModule(); EmbeddedResourceLoader embedded = new EmbeddedResourceLoader(); embedded.Add("/", Assembly.GetExecutingAssembly(), Assembly.GetExecutingAssembly().GetName().Name, Assembly.GetExecutingAssembly().GetName().Name + @".Resources.favicon.ico"); fileModule.Resources.Add(embedded); server.Add(fileModule); server.Add(new SimpleRouter("/favicon.ico", "/resources/favicon.ico")); server.Start(5); Console.WriteLine(string.Format("Start {0} on {1}.", httpServerName, httpBindingPort)); Console.WriteLine(); Console.WriteLine("Press any key to close service."); Console.ReadKey(); server.Stop(true); activator.Stop(); }
static void Main(string[] args) { LogFactory.Assign(new ConsoleLogFactory()); ServiceProvider.Bootstrap(); ServiceHostInfo info = new ServiceHostInfo(); info.Name = ConfigurationMaster.Get(ServiceConfiguration.DefaultServiceConfigurationName); info.Address = Dns.GetHostName(); info.Port = int.Parse(ConfigurationMaster.Get(ServiceConfiguration.DefaultServicePortConfigurationName)); info.Binding = new NetTcpBinding(ServiceConfiguration.DefaultNetTcpBindingName); info.Contract = typeof(IDeviceProfileService); info.Service = typeof(DeviceProfileService); Console.WriteLine(string.Format(@"Service is starting on [{0}]", info.ToString())); ManagedServiceHostActivator<IDeviceProfileService> activator = new ManagedServiceHostActivator<IDeviceProfileService>(info); activator.Start(); Console.WriteLine(string.Format(@"Service address [{0}]", activator.ServiceHost.Description.Endpoints.First().Address)); string serverName = ConfigurationMaster.Get(@"HttpServerName"); string httpServerName = serverName + " HTTP Server"; int httpBindingPort = int.Parse(ConfigurationMaster.Get(@"HttpServerPort")); Server server = null; server = new Server(httpServerName); server.Add(HttpListenerFactory.Create(IPAddress.Any, httpBindingPort)); server.Add(new CameraListModule()); server.Add(new CameraModule()); server.Add(new CameraThumbnailModule()); FileModule fileModule = new FileModule(); EmbeddedResourceLoader embedded = new EmbeddedResourceLoader(); embedded.Add("/", Assembly.GetExecutingAssembly(), Assembly.GetExecutingAssembly().GetName().Name, Assembly.GetExecutingAssembly().GetName().Name + @".Resources.favicon.ico"); fileModule.Resources.Add(embedded); server.Add(fileModule); server.Add(new SimpleRouter("/favicon.ico", "/resources/favicon.ico")); server.Start(5); Console.WriteLine(string.Format("Start {0} on {1}.", httpServerName, httpBindingPort)); Console.WriteLine(); Console.WriteLine("Press any key to close service."); Console.ReadKey(); server.Stop(true); activator.Stop(); }