
//  Copyright (c) Microsoft Corporation.  All Rights Reserved.

using System;
using System.Collections.Generic;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
using System.ServiceModel.Routing;

namespace Microsoft.Samples.ServiceModel
{
    public class Router
    {

        // Host the service within this EXE console application.
        public static void Main()
        {
            // Create a ServiceHost for the RoutingService type.
            using (ServiceHost serviceHost =
                new ServiceHost(typeof(RoutingService)))
            {
                // Open the ServiceHost to create listeners         
                // and start listening for messages.
                Console.WriteLine("The Routing Service configured, opening....");
                try
                {
                    serviceHost.Open();
                    Console.WriteLine("The Routing Service is now running.");
                    Console.WriteLine("Press <ENTER> to terminate router.");

                    // The service can now be accessed.
                    Console.ReadLine();
                    serviceHost.Close();
                }
                catch (CommunicationException)
                {
                    serviceHost.Abort();
                }
            }
        }
    }
    

}
