CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Language: C#

TopShelf

167 Views
Copy Code Show/Hide Line Numbers
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();
        }
    }
}
by Barry Forrest
  March 09, 2010 @ 1:34pm

Add a comment


Report Abuse
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate