Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Hive.Client.Core/3.2/ClientConsoleService/ClientConsoleServer.cs @ 3200

Last change on this file since 3200 was 2591, checked in by gkronber, 15 years ago

Copied refactored plugin infrastructure from branch and merged changeset r2586:2589 from branch into the trunk. #799

File size: 1.6 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.ServiceModel.Description;
6using System.ServiceModel;
7using HeuristicLab.PluginInfrastructure;
8using HeuristicLab.Hive.Client.Core.ClientConsoleService.Interfaces;
9using HeuristicLab.Hive.Contracts;
10
11namespace HeuristicLab.Hive.Client.Core.ClientConsoleService {
12  public class ClientConsoleServer {
13
14    private bool AddMexEndpoint(ServiceHost serviceHost) {
15      if (serviceHost != null) {
16        ServiceMetadataBehavior behavior =
17            new ServiceMetadataBehavior();
18        serviceHost.Description.Behaviors.Add(behavior);
19
20        return serviceHost.AddServiceEndpoint(
21          typeof(IMetadataExchange),
22          MetadataExchangeBindings.CreateMexTcpBinding(),
23          "mex") != null;
24      } else
25        return false;
26    }
27   
28    public ServiceHost StartClientConsoleServer(Uri uriTcp) {
29      IEnumerable<IClientConsoleCommunicator> clientConsoleServerInstances =
30        ApplicationManager.Manager.GetInstances<IClientConsoleCommunicator>();
31
32      if (clientConsoleServerInstances.Count() > 0) {
33        ServiceHost serviceHost =
34                new ServiceHost(clientConsoleServerInstances.First().GetType(),
35                  uriTcp);
36
37        serviceHost.AddServiceEndpoint(
38          typeof(IClientConsoleCommunicator),
39              WcfSettings.GetBinding(),
40              "ClientConsoleCommunicator");
41
42        AddMexEndpoint(serviceHost);
43
44        serviceHost.Open();
45        return serviceHost;
46      } else {
47        return null;
48      }
49    }
50  }
51}
Note: See TracBrowser for help on using the repository browser.