Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OKB/HeuristicLab.Services.OKB/3.3/Convert.cs @ 4481

Last change on this file since 4481 was 4481, checked in by swagner, 14 years ago

Worked on OKB (#1174)

File size: 7.3 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2010 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.Data.Linq;
23using DA = HeuristicLab.Services.OKB.DataAccess;
24using DT = HeuristicLab.Services.OKB.DataTransfer;
25
26namespace HeuristicLab.Services.OKB {
27  public static class Convert {
28    #region Platform
29    public static DT.Platform ToDto(DA.Platform source) {
30      if (source == null) return null;
31      return new DT.Platform { Id = source.Id, Name = source.Name, Description = source.Description };
32    }
33    public static DA.Platform ToEntity(DT.Platform source) {
34      if (source == null) return null;
35      return new DA.Platform { Id = source.Id, Name = source.Name, Description = source.Description };
36    }
37    public static void ToEntity(DT.Platform source, DA.Platform target) {
38      if ((source != null) && (target != null))
39        target.Id = source.Id; target.Name = source.Name; target.Description = source.Description;
40    }
41    #endregion
42
43    #region DataType
44    public static DT.DataType ToDto(DA.DataType source) {
45      if (source == null) return null;
46      return new DT.DataType { Id = source.Id, Name = source.Name, SqlName = source.SqlName, PlatformId = source.PlatformId };
47    }
48    public static DA.DataType ToEntity(DT.DataType source) {
49      if (source == null) return null;
50      return new DA.DataType { Id = source.Id, Name = source.Name, SqlName = source.SqlName, PlatformId = source.PlatformId };
51    }
52    public static void ToEntity(DT.DataType source, DA.DataType target) {
53      if ((source != null) && (target != null))
54        target.Id = source.Id; target.Name = source.Name; target.SqlName = source.SqlName; target.PlatformId = source.PlatformId;
55    }
56    #endregion
57
58    #region AlgorithmClass
59    public static DT.AlgorithmClass ToDto(DA.AlgorithmClass source) {
60      if (source == null) return null;
61      return new DT.AlgorithmClass { Id = source.Id, Name = source.Name, Description = source.Description };
62    }
63    public static DA.AlgorithmClass ToEntity(DT.AlgorithmClass source) {
64      if (source == null) return null;
65      return new DA.AlgorithmClass { Id = source.Id, Name = source.Name, Description = source.Description };
66    }
67    public static void ToEntity(DT.AlgorithmClass source, DA.AlgorithmClass target) {
68      if ((source != null) && (target != null))
69        target.Id = source.Id; target.Name = source.Name; target.Description = source.Description;
70    }
71    #endregion
72
73    #region Algorithm
74    public static DT.Algorithm ToDto(DA.Algorithm source) {
75      if (source == null) return null;
76      return new DT.Algorithm { Id = source.Id, Name = source.Name, Description = source.Description, PlatformId = source.PlatformId, AlgorithmClassId = source.AlgorithmClassId };
77    }
78    public static DA.Algorithm ToEntity(DT.Algorithm source) {
79      if (source == null) return null;
80      return new DA.Algorithm { Id = source.Id, Name = source.Name, Description = source.Description, PlatformId = source.PlatformId, AlgorithmClassId = source.AlgorithmClassId };
81    }
82    public static void ToEntity(DT.Algorithm source, DA.Algorithm target) {
83      if ((source != null) && (target != null))
84        target.Id = source.Id; target.Name = source.Name; target.Description = source.Description; target.PlatformId = source.PlatformId; target.AlgorithmClassId = source.AlgorithmClassId;
85    }
86    #endregion
87
88    #region AlgorithmData
89    public static DT.AlgorithmData ToDto(DA.AlgorithmData source) {
90      if (source == null) return null;
91      return new DT.AlgorithmData { AlgorithmId = source.AlgorithmId, DataTypeId = source.DataTypeId, Data = source.Data.ToArray() };
92    }
93    public static DA.AlgorithmData ToEntity(DT.AlgorithmData source) {
94      if (source == null) return null;
95      return new DA.AlgorithmData { AlgorithmId = source.AlgorithmId, DataTypeId = source.DataTypeId, Data = new Binary(source.Data) };
96    }
97    public static void ToEntity(DT.AlgorithmData source, DA.AlgorithmData target) {
98      if ((source != null) && (target != null))
99        target.AlgorithmId = source.AlgorithmId; target.DataTypeId = source.DataTypeId; target.Data = new Binary(source.Data);
100    }
101    #endregion
102
103    #region ProblemClass
104    public static DT.ProblemClass ToDto(DA.ProblemClass source) {
105      if (source == null) return null;
106      return new DT.ProblemClass { Id = source.Id, Name = source.Name, Description = source.Description };
107    }
108    public static DA.ProblemClass ToEntity(DT.ProblemClass source) {
109      if (source == null) return null;
110      return new DA.ProblemClass { Id = source.Id, Name = source.Name, Description = source.Description };
111    }
112    public static void ToEntity(DT.ProblemClass source, DA.ProblemClass target) {
113      if ((source != null) && (target != null))
114        target.Id = source.Id; target.Name = source.Name; target.Description = source.Description;
115    }
116    #endregion
117
118    #region Algorithm
119    public static DT.Problem ToDto(DA.Problem source) {
120      if (source == null) return null;
121      return new DT.Problem { Id = source.Id, Name = source.Name, Description = source.Description, PlatformId = source.PlatformId, ProblemClassId = source.ProblemClassId };
122    }
123    public static DA.Problem ToEntity(DT.Problem source) {
124      if (source == null) return null;
125      return new DA.Problem { Id = source.Id, Name = source.Name, Description = source.Description, PlatformId = source.PlatformId, ProblemClassId = source.ProblemClassId };
126    }
127    public static void ToEntity(DT.Problem source, DA.Problem target) {
128      if ((source != null) && (target != null))
129        target.Id = source.Id; target.Name = source.Name; target.Description = source.Description; target.PlatformId = source.PlatformId; target.ProblemClassId = source.ProblemClassId;
130    }
131    #endregion
132
133    #region ProblemData
134    public static DT.ProblemData ToDto(DA.ProblemData source) {
135      if (source == null) return null;
136      return new DT.ProblemData { ProblemId = source.ProblemId, DataTypeId = source.DataTypeId, Data = source.Data.ToArray() };
137    }
138    public static DA.ProblemData ToEntity(DT.ProblemData source) {
139      if (source == null) return null;
140      return new DA.ProblemData { ProblemId = source.ProblemId, DataTypeId = source.DataTypeId, Data = new Binary(source.Data) };
141    }
142    public static void ToEntity(DT.ProblemData source, DA.ProblemData target) {
143      if ((source != null) && (target != null))
144        target.ProblemId = source.ProblemId; target.DataTypeId = source.DataTypeId; target.Data = new Binary(source.Data);
145    }
146    #endregion
147  }
148}
Note: See TracBrowser for help on using the repository browser.