#region License Information /* HeuristicLab * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using System.ServiceModel; using HeuristicLab.Clients.Hive.Slave; using HeuristicLab.Clients.Hive.Slave.ServiceContracts; namespace HeuristicLab.Clients.Hive.Slave { /// /// Singleton which encapsulates the SlaveCommunicationService /// public class SlaveClientCom { private static SlaveClientCom instance; private static DuplexChannelFactory pipeFactory; /// /// Getter for the Instance of the SlaveClientCom /// /// the Instance of the SlaveClientCom class public static SlaveClientCom Instance { get { if (instance == null) { instance = new SlaveClientCom(); } return instance; } } public ISlaveCommunication ClientCom { get; set; } private SlaveClientCom() { setupClientCom(); } private void setupClientCom() { DummyListener dummy = new DummyListener(); pipeFactory = new DuplexChannelFactory( dummy, new NetNamedPipeBinding(), new EndpointAddress("net.pipe://localhost/HeuristicLabSlaveCom")); ISlaveCommunication pipeProxy = pipeFactory.CreateChannel(); ClientCom = pipeProxy; } public static void Close() { if (pipeFactory.State != CommunicationState.Closed) pipeFactory.Close(); } } }