Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 630 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
RevLine 
[372]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;
[357]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;
[560]31using HeuristicLab.CEDMA.Charting;
[357]32
[377]33namespace HeuristicLab.CEDMA.Core {
[357]34  public class Console : ItemBase, IEditable {
35    private AgentList agentList;
[553]36    private ResultList resultsList;
[417]37    private DatabaseOperatorLibrary operatorLibary;
[357]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
[553]49    public ResultList ResultsList {
50      get { return resultsList; }
51    }
52
[417]53    public IOperatorLibrary OperatorLibrary {
54      get { return operatorLibary; }
55    }
56
[357]57    public Console()
58      : base() {
59      agentList = new AgentList();
[553]60      resultsList = new ResultList();
[417]61      operatorLibary = new DatabaseOperatorLibrary();
[357]62    }
63
64    public IEditor CreateEditor() {
65      return new ConsoleEditor(this);
66    }
67
[383]68    public override IView CreateView() {
[357]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);
[359]83      serverUri = node.Attributes["ServerURI"].Value;
[357]84    }
85    #endregion
86
87    #region WCF
88    private void ResetConnection() {
89      NetTcpBinding binding = new NetTcpBinding();
[492]90      binding.MaxReceivedMessageSize = 100000000; // 100Mbytes
91      binding.ReaderQuotas.MaxStringContentLength = 100000000; // also 100M chars
92      binding.ReaderQuotas.MaxArrayLength = 100000000; // also 100M elements;
[357]93      binding.Security.Mode = SecurityMode.None;
94      factory = new ChannelFactory<IDatabase>(binding);
95      database = factory.CreateChannel(new EndpointAddress(serverUri));
96      agentList.Database = database;
[417]97      operatorLibary.Database = database;
[553]98
99      ChannelFactory<IStore> storeFactory = new ChannelFactory<IStore>(binding);
100      IStore store = storeFactory.CreateChannel(new EndpointAddress(serverUri + "/RdfStore"));
101      resultsList.Store = store;
[357]102    }
103    #endregion
[359]104
105    internal void Connect(string serverUri) {
106      this.serverUri = serverUri;
107      ResetConnection();
108    }
[357]109  }
110}
Note: See TracBrowser for help on using the repository browser.