Language: C#
TopShelf
namespace Xterprise.Clarity.Ars.BusTerminal { using System; using System.ServiceModel; using Xterprise.Clarity.Ars.Commands.ForInventory; using Xterprise.Clarity.Ars.Contracts; /// <summary> /// Controls the services which are hosted as wcf endpoints. /// </summary> public class HostService { protected const string endPoint = @"net.tcp://localhost:8002"; private ServiceHost inventoryHost; private ServiceHost lookupHost; private IInventoryCommands inventoryPublisher; private ILookupOperations lookupProvider; public HostService(IInventoryCommands inventory, ILookupOperations lookup) { inventoryPublisher = inventory; lookupProvider = lookup; } public void Start() { Logger.Information("Starting inventory host"); inventoryHost = new ServiceHost(inventoryPublisher, new Uri(endPoint)); inventoryHost.Open(); Logger.Information("Inventory host started"); Console.WriteLine("Inventory host started"); Logger.Information("Starting Lookup host"); lookupHost = new ServiceHost(lookupProvider.GetType(), new Uri(endPoint)); lookupHost.Open(); Logger.Information("Lookup host started"); } /// <summary> /// Closes the services. /// </summary> public void Stop() { Logger.Information("Stopping inventory host"); inventoryHost.Close(); Logger.Information("Stopping lookup host"); lookupHost.Close(); } } }
Report Abuse
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search

