Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.CEDMA.Core/Console.cs @ 560

Last change on this file since 560 was 560, checked in by gkronber, 16 years ago
  • added strong name key to CEDMA.Charting.
  • moved classes related to charting from CEDMA.Core to CEDMA.Charting

#268

File size: 3.6 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.Linq;
25using System.Text;
26using HeuristicLab.Core;
27using System.Xml;
28using System.ServiceModel;
29using System.ServiceModel.Description;
30using HeuristicLab.CEDMA.DB.Interfaces;
31using HeuristicLab.CEDMA.Charting;
32
33namespace HeuristicLab.CEDMA.Core {
34  public class Console : ItemBase, IEditable {
35    private AgentList agentList;
36    private ResultList resultsList;
37    private DatabaseOperatorLibrary operatorLibary;
38    private ChannelFactory<IDatabase> factory;
39    private IDatabase database;
40    private string serverUri;
41    public string ServerUri {
42      get { return serverUri; }
43    }
44
45    public IAgentList AgentList {
46      get { return agentList; }
47    }
48
49    public ResultList ResultsList {
50      get { return resultsList; }
51    }
52
53    public IOperatorLibrary OperatorLibrary {
54      get { return operatorLibary; }
55    }
56
57    public Console()
58      : base() {
59      agentList = new AgentList();
60      resultsList = new ResultList();
61      operatorLibary = new DatabaseOperatorLibrary();
62    }
63
64    public IEditor CreateEditor() {
65      return new ConsoleEditor(this);
66    }
67
68    public override IView CreateView() {
69      return new ConsoleEditor(this);
70    }
71
72    #region serialization
73    public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) {
74      XmlNode node = base.GetXmlNode(name, document, persistedObjects);
75      XmlAttribute uriAttribute = document.CreateAttribute("ServerURI");
76      uriAttribute.Value = serverUri;
77      node.Attributes.Append(uriAttribute);
78      return node;
79    }
80
81    public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
82      base.Populate(node, restoredObjects);
83      serverUri = node.Attributes["ServerURI"].Value;
84    }
85    #endregion
86
87    #region WCF
88    private void ResetConnection() {
89      NetTcpBinding binding = new NetTcpBinding();
90      binding.MaxReceivedMessageSize = 100000000; // 100Mbytes
91      binding.ReaderQuotas.MaxStringContentLength = 100000000; // also 100M chars
92      binding.ReaderQuotas.MaxArrayLength = 100000000; // also 100M elements;
93      binding.Security.Mode = SecurityMode.None;
94      factory = new ChannelFactory<IDatabase>(binding);
95      database = factory.CreateChannel(new EndpointAddress(serverUri));
96      agentList.Database = database;
97      operatorLibary.Database = database;
98
99      ChannelFactory<IStore> storeFactory = new ChannelFactory<IStore>(binding);
100      IStore store = storeFactory.CreateChannel(new EndpointAddress(serverUri + "/RdfStore"));
101      resultsList.Store = store;
102    }
103    #endregion
104
105    internal void Connect(string serverUri) {
106      this.serverUri = serverUri;
107      ResetConnection();
108    }
109  }
110}
Note: See TracBrowser for help on using the repository browser.