Free cookie consent management tool by TermsFeed Policy Generator

source: branches/MPI/HeuristicLab.Operators.MPISupport/3.3/BinaryTransport/Core/ScopeTransfer.cs @ 7544

Last change on this file since 7544 was 7544, checked in by svonolfe, 12 years ago

Improved performance, added MPISolutionsCreator (#1542)

File size: 1.5 KB
RevLine 
[7544]1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using HeuristicLab.Core;
6
7namespace HeuristicLab.Operators.MPISupport.BinaryTransport {
8  [Serializable]
9  class ScopeTransfer {
10    public string Name { get; set; }
11    public string Description { get; set; }
12    public List<VariableTransfer> Variables { get; set; }
13    public List<ScopeTransfer> SubScopes { get; set; }
14
15    public ScopeTransfer() {
16      Variables = new List<VariableTransfer>();
17      SubScopes = new List<ScopeTransfer>();
18    }
19
20    public static ScopeTransfer Convert(IScope item) {
21      ScopeTransfer result = new ScopeTransfer();
22
23      result.Name = item.Name;
24      result.Description = item.Description;
25
26      foreach (IVariable variable in item.Variables) {
27        result.Variables.Add(VariableTransfer.Convert(variable));
28      }
29
30      foreach (IScope subscope in item.SubScopes) {
31        result.SubScopes.Add(Convert(subscope));
32      }
33
34      return result;
35    }
36
37    public static IScope Convert(ScopeTransfer item, IExecutionContext globalScope) {
38      IScope result = new Scope();
39
40      result.Name = item.Name;
41      result.Description = item.Description;
42
43      foreach (VariableTransfer variable in item.Variables) {
44        result.Variables.Add(VariableTransfer.Convert(variable, globalScope));
45      }
46
47      foreach (ScopeTransfer subscope in item.SubScopes) {
48        result.SubScopes.Add(Convert(subscope, globalScope));
49      }
50
51      return result;
52    }
53  }
54}
Note: See TracBrowser for help on using the repository browser.