/// <summary>
 /// Initializes a new instance of the <see cref="GenericWcfService"/> class using the
 /// specified service environment.
 /// </summary>
 /// <param name="environment">A <see cref="ServiceEnvironment"/> comprising the WCF
 /// services that are part of the application.</param>
 public GenericWcfService(ServiceEnvironment environment)
     : base()
 {
     if (environment == null)
         throw new ArgumentNullException("environment");
     this.environment = environment;
     InitializeComponent();
 }
 /// <summary>
 /// Starts a service console using the specified environment.
 /// </summary>
 /// <param name="environment">A <see cref="ServiceEnvironment"/> initialized with the
 /// <see cref="IServiceHostFactory"/> instances responsible for instantiating individual
 /// service hosts.</param>
 public static void Run(ServiceEnvironment environment)
 {
     if (environment == null)
         throw new ArgumentNullException("environment");
     Console.TreatControlCAsInput = false;
     bool aborted = false;
     Console.CancelKeyPress += (sender, e) =>
     {
         Console.WriteLine();
         Console.WriteLine("Interrupted - shutting down services");
         e.Cancel = false;
         aborted = true;
         environment.Dispose();
         Console.WriteLine("All services shut down.");
     };
     environment.Start();
     if (aborted)
         return;
     Console.WriteLine("Server started. To safely shut down, press Ctrl+C.");
     while (true)
         Console.ReadLine();
 }