Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OKB (trunk integration)/HeuristicLab.Services.OKB/3.3/Convert.cs @ 5482

Last change on this file since 5482 was 5459, checked in by swagner, 13 years ago

Worked on OKB (#1174)

File size: 31.7 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.Collections.Generic;
23using System.Data.Linq;
24using System.Linq;
25using DA = HeuristicLab.Services.OKB.DataAccess;
26using DT = HeuristicLab.Services.OKB.DataTransfer;
27
28namespace HeuristicLab.Services.OKB {
29  public static class Convert {
30    #region Platform
31    public static DT.Platform ToDto(DA.Platform source) {
32      if (source == null) return null;
33      return new DT.Platform { Id = source.Id, Name = source.Name, Description = source.Description };
34    }
35    public static DA.Platform ToEntity(DT.Platform source) {
36      if (source == null) return null;
37      return new DA.Platform { Id = source.Id, Name = source.Name, Description = source.Description };
38    }
39    public static void ToEntity(DT.Platform source, DA.Platform target) {
40      if ((source != null) && (target != null)) {
41        target.Id = source.Id; target.Name = source.Name; target.Description = source.Description;
42      }
43    }
44    #endregion
45
46    #region DataType
47    public static DT.DataType ToDto(DA.DataType source) {
48      if (source == null) return null;
49      return new DT.DataType { Id = source.Id, Name = source.Name, TypeName = source.TypeName, PlatformId = source.PlatformId };
50    }
51    public static DA.DataType ToEntity(DT.DataType source) {
52      if (source == null) return null;
53      return new DA.DataType { Id = source.Id, Name = source.Name, TypeName = source.TypeName, PlatformId = source.PlatformId };
54    }
55    #endregion
56
57    #region BinaryData
58    public static DT.BinaryData ToDto(DA.BinaryData source) {
59      if (source == null) return null;
60      return new DT.BinaryData { Id = source.Id, Data = source.Data.ToArray() };
61    }
62    public static DA.BinaryData ToEntity(DT.BinaryData source) {
63      if (source == null) return null;
64      return new DA.BinaryData { Id = source.Id, Data = source.Data };
65    }
66    public static void ToEntity(DT.BinaryData source, DA.BinaryData target) {
67      if ((source != null) && (target != null)) {
68        target.Id = source.Id; target.Data = source.Data;
69      }
70    }
71    #endregion
72
73    #region AlgorithmClass
74    public static DT.AlgorithmClass ToDto(DA.AlgorithmClass source) {
75      if (source == null) return null;
76      return new DT.AlgorithmClass { Id = source.Id, Name = source.Name, Description = source.Description };
77    }
78    public static DA.AlgorithmClass ToEntity(DT.AlgorithmClass source) {
79      if (source == null) return null;
80      return new DA.AlgorithmClass { Id = source.Id, Name = source.Name, Description = source.Description };
81    }
82    public static void ToEntity(DT.AlgorithmClass source, DA.AlgorithmClass target) {
83      if ((source != null) && (target != null)) {
84        target.Id = source.Id; target.Name = source.Name; target.Description = source.Description;
85      }
86    }
87    #endregion
88
89    #region Algorithm
90    public static DT.Algorithm ToDto(DA.Algorithm source) {
91      if (source == null) return null;
92      return new DT.Algorithm { Id = source.Id, Name = source.Name, Description = source.Description, PlatformId = source.PlatformId, AlgorithmClassId = source.AlgorithmClassId, DataTypeId = source.DataTypeId, BinaryDataId = source.BinaryDataId };
93    }
94    public static DA.Algorithm ToEntity(DT.Algorithm source) {
95      if (source == null) return null;
96      return new DA.Algorithm { Id = source.Id, Name = source.Name, Description = source.Description, PlatformId = source.PlatformId, AlgorithmClassId = source.AlgorithmClassId, DataTypeId = source.DataTypeId, BinaryDataId = source.BinaryDataId };
97    }
98    public static void ToEntity(DT.Algorithm source, DA.Algorithm target) {
99      if ((source != null) && (target != null)) {
100        target.Id = source.Id; target.Name = source.Name; target.Description = source.Description; target.PlatformId = source.PlatformId; target.AlgorithmClassId = source.AlgorithmClassId; target.DataTypeId = source.DataTypeId; target.BinaryDataId = source.BinaryDataId;
101      }
102    }
103    #endregion
104
105    #region AlgorithmParameter
106    public static DT.AlgorithmParameter ToDto(DA.AlgorithmParameter source) {
107      if (source == null) return null;
108      return new DT.AlgorithmParameter { Id = source.Id, Name = source.Name, Description = source.Description, Alias = source.Alias, AlgorithmId = source.AlgorithmId, DataTypeId = source.DataTypeId };
109    }
110    public static DA.AlgorithmParameter ToEntity(DT.AlgorithmParameter source) {
111      if (source == null) return null;
112      return new DA.AlgorithmParameter { Id = source.Id, Name = source.Name, Description = source.Description, Alias = source.Alias, AlgorithmId = source.AlgorithmId, DataTypeId = source.DataTypeId };
113    }
114    public static void ToEntity(DT.AlgorithmParameter source, DA.AlgorithmParameter target) {
115      if ((source != null) && (target != null)) {
116        target.Id = source.Id; target.Name = source.Name; target.Description = source.Description; target.Alias = source.Alias; target.AlgorithmId = source.AlgorithmId; target.DataTypeId = source.DataTypeId;
117      }
118    }
119    #endregion
120
121    #region AlgorithmParameterBlobValue
122    public static DT.AlgorithmParameterBlobValue ToDto(DA.AlgorithmParameterBlobValue source) {
123      if (source == null) return null;
124      return new DT.AlgorithmParameterBlobValue { AlgorithmParameterId = source.AlgorithmParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = source.Value.ToArray() };
125    }
126    public static DA.AlgorithmParameterBlobValue ToEntity(DT.AlgorithmParameterBlobValue source) {
127      if (source == null) return null;
128      return new DA.AlgorithmParameterBlobValue { AlgorithmParameterId = source.AlgorithmParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = new Binary(source.Value) };
129    }
130    public static void ToEntity(DT.AlgorithmParameterBlobValue source, DA.AlgorithmParameterBlobValue target) {
131      if ((source != null) && (target != null)) {
132        target.AlgorithmParameterId = source.AlgorithmParameterId; target.ExperimentId = source.ExperimentId; target.DataTypeId = source.DataTypeId; target.Value = new Binary(source.Value);
133      }
134    }
135    #endregion
136
137    #region AlgorithmParameterBoolValue
138    public static DT.AlgorithmParameterBoolValue ToDto(DA.AlgorithmParameterBoolValue source) {
139      if (source == null) return null;
140      return new DT.AlgorithmParameterBoolValue { AlgorithmParameterId = source.AlgorithmParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = source.Value };
141    }
142    public static DA.AlgorithmParameterBoolValue ToEntity(DT.AlgorithmParameterBoolValue source) {
143      if (source == null) return null;
144      return new DA.AlgorithmParameterBoolValue { AlgorithmParameterId = source.AlgorithmParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = source.Value };
145    }
146    public static void ToEntity(DT.AlgorithmParameterBoolValue source, DA.AlgorithmParameterBoolValue target) {
147      if ((source != null) && (target != null)) {
148        target.AlgorithmParameterId = source.AlgorithmParameterId; target.ExperimentId = source.ExperimentId; target.DataTypeId = source.DataTypeId; target.Value = source.Value;
149      }
150    }
151    #endregion
152
153    #region AlgorithmParameterFloatValue
154    public static DT.AlgorithmParameterFloatValue ToDto(DA.AlgorithmParameterFloatValue source) {
155      if (source == null) return null;
156      return new DT.AlgorithmParameterFloatValue { AlgorithmParameterId = source.AlgorithmParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = source.Value };
157    }
158    public static DA.AlgorithmParameterFloatValue ToEntity(DT.AlgorithmParameterFloatValue source) {
159      if (source == null) return null;
160      return new DA.AlgorithmParameterFloatValue { AlgorithmParameterId = source.AlgorithmParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = source.Value };
161    }
162    public static void ToEntity(DT.AlgorithmParameterFloatValue source, DA.AlgorithmParameterFloatValue target) {
163      if ((source != null) && (target != null)) {
164        target.AlgorithmParameterId = source.AlgorithmParameterId; target.ExperimentId = source.ExperimentId; target.DataTypeId = source.DataTypeId; target.Value = source.Value;
165      }
166    }
167    #endregion
168
169    #region AlgorithmParameterIntValue
170    public static DT.AlgorithmParameterIntValue ToDto(DA.AlgorithmParameterIntValue source) {
171      if (source == null) return null;
172      return new DT.AlgorithmParameterIntValue { AlgorithmParameterId = source.AlgorithmParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = source.Value };
173    }
174    public static DA.AlgorithmParameterIntValue ToEntity(DT.AlgorithmParameterIntValue source) {
175      if (source == null) return null;
176      return new DA.AlgorithmParameterIntValue { AlgorithmParameterId = source.AlgorithmParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = source.Value };
177    }
178    public static void ToEntity(DT.AlgorithmParameterIntValue source, DA.AlgorithmParameterIntValue target) {
179      if ((source != null) && (target != null)) {
180        target.AlgorithmParameterId = source.AlgorithmParameterId; target.ExperimentId = source.ExperimentId; target.DataTypeId = source.DataTypeId; target.Value = source.Value;
181      }
182    }
183    #endregion
184
185    #region AlgorithmParameterStringValue
186    public static DT.AlgorithmParameterStringValue ToDto(DA.AlgorithmParameterStringValue source) {
187      if (source == null) return null;
188      return new DT.AlgorithmParameterStringValue { AlgorithmParameterId = source.AlgorithmParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = source.Value };
189    }
190    public static DA.AlgorithmParameterStringValue ToEntity(DT.AlgorithmParameterStringValue source) {
191      if (source == null) return null;
192      return new DA.AlgorithmParameterStringValue { AlgorithmParameterId = source.AlgorithmParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = source.Value };
193    }
194    public static void ToEntity(DT.AlgorithmParameterStringValue source, DA.AlgorithmParameterStringValue target) {
195      if ((source != null) && (target != null)) {
196        target.AlgorithmParameterId = source.AlgorithmParameterId; target.ExperimentId = source.ExperimentId; target.DataTypeId = source.DataTypeId; target.Value = source.Value;
197      }
198    }
199    #endregion
200
201    #region ProblemClass
202    public static DT.ProblemClass ToDto(DA.ProblemClass source) {
203      if (source == null) return null;
204      return new DT.ProblemClass { Id = source.Id, Name = source.Name, Description = source.Description };
205    }
206    public static DA.ProblemClass ToEntity(DT.ProblemClass source) {
207      if (source == null) return null;
208      return new DA.ProblemClass { Id = source.Id, Name = source.Name, Description = source.Description };
209    }
210    public static void ToEntity(DT.ProblemClass source, DA.ProblemClass target) {
211      if ((source != null) && (target != null)) {
212        target.Id = source.Id; target.Name = source.Name; target.Description = source.Description;
213      }
214    }
215    #endregion
216
217    #region Problem
218    public static DT.Problem ToDto(DA.Problem source) {
219      if (source == null) return null;
220      return new DT.Problem { Id = source.Id, Name = source.Name, Description = source.Description, PlatformId = source.PlatformId, ProblemClassId = source.ProblemClassId, DataTypeId = source.DataTypeId, BinaryDataId = source.BinaryDataId };
221    }
222    public static DA.Problem ToEntity(DT.Problem source) {
223      if (source == null) return null;
224      return new DA.Problem { Id = source.Id, Name = source.Name, Description = source.Description, PlatformId = source.PlatformId, ProblemClassId = source.ProblemClassId, DataTypeId = source.DataTypeId, BinaryDataId = source.BinaryDataId };
225    }
226    public static void ToEntity(DT.Problem source, DA.Problem target) {
227      if ((source != null) && (target != null)) {
228        target.Id = source.Id; target.Name = source.Name; target.Description = source.Description; target.PlatformId = source.PlatformId; target.ProblemClassId = source.ProblemClassId; target.DataTypeId = source.DataTypeId; target.BinaryDataId = source.BinaryDataId;
229      }
230    }
231    #endregion
232
233    #region ProblemParameter
234    public static DT.ProblemParameter ToDto(DA.ProblemParameter source) {
235      if (source == null) return null;
236      return new DT.ProblemParameter { Id = source.Id, Name = source.Name, Description = source.Description, Alias = source.Alias, ProblemId = source.ProblemId, DataTypeId = source.DataTypeId };
237    }
238    public static DA.ProblemParameter ToEntity(DT.ProblemParameter source) {
239      if (source == null) return null;
240      return new DA.ProblemParameter { Id = source.Id, Name = source.Name, Description = source.Description, Alias = source.Alias, ProblemId = source.ProblemId, DataTypeId = source.DataTypeId };
241    }
242    public static void ToEntity(DT.ProblemParameter source, DA.ProblemParameter target) {
243      if ((source != null) && (target != null)) {
244        target.Id = source.Id; target.Name = source.Name; target.Description = source.Description; target.Alias = source.Alias; target.ProblemId = source.ProblemId; target.DataTypeId = source.DataTypeId;
245      }
246    }
247    #endregion
248
249    #region ProblemParameterBlobValue
250    public static DT.ProblemParameterBlobValue ToDto(DA.ProblemParameterBlobValue source) {
251      if (source == null) return null;
252      return new DT.ProblemParameterBlobValue { ProblemParameterId = source.ProblemParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = source.Value.ToArray() };
253    }
254    public static DA.ProblemParameterBlobValue ToEntity(DT.ProblemParameterBlobValue source) {
255      if (source == null) return null;
256      return new DA.ProblemParameterBlobValue { ProblemParameterId = source.ProblemParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = new Binary(source.Value) };
257    }
258    public static void ToEntity(DT.ProblemParameterBlobValue source, DA.ProblemParameterBlobValue target) {
259      if ((source != null) && (target != null)) {
260        target.ProblemParameterId = source.ProblemParameterId; target.ExperimentId = source.ExperimentId; target.DataTypeId = source.DataTypeId; target.Value = new Binary(source.Value);
261      }
262    }
263    #endregion
264
265    #region ProblemParameterBoolValue
266    public static DT.ProblemParameterBoolValue ToDto(DA.ProblemParameterBoolValue source) {
267      if (source == null) return null;
268      return new DT.ProblemParameterBoolValue { ProblemParameterId = source.ProblemParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = source.Value };
269    }
270    public static DA.ProblemParameterBoolValue ToEntity(DT.ProblemParameterBoolValue source) {
271      if (source == null) return null;
272      return new DA.ProblemParameterBoolValue { ProblemParameterId = source.ProblemParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = source.Value };
273    }
274    public static void ToEntity(DT.ProblemParameterBoolValue source, DA.ProblemParameterBoolValue target) {
275      if ((source != null) && (target != null)) {
276        target.ProblemParameterId = source.ProblemParameterId; target.ExperimentId = source.ExperimentId; target.DataTypeId = source.DataTypeId; target.Value = source.Value;
277      }
278    }
279    #endregion
280
281    #region ProblemParameterFloatValue
282    public static DT.ProblemParameterFloatValue ToDto(DA.ProblemParameterFloatValue source) {
283      if (source == null) return null;
284      return new DT.ProblemParameterFloatValue { ProblemParameterId = source.ProblemParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = source.Value };
285    }
286    public static DA.ProblemParameterFloatValue ToEntity(DT.ProblemParameterFloatValue source) {
287      if (source == null) return null;
288      return new DA.ProblemParameterFloatValue { ProblemParameterId = source.ProblemParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = source.Value };
289    }
290    public static void ToEntity(DT.ProblemParameterFloatValue source, DA.ProblemParameterFloatValue target) {
291      if ((source != null) && (target != null)) {
292        target.ProblemParameterId = source.ProblemParameterId; target.ExperimentId = source.ExperimentId; target.DataTypeId = source.DataTypeId; target.Value = source.Value;
293      }
294    }
295    #endregion
296
297    #region ProblemParameterIntValue
298    public static DT.ProblemParameterIntValue ToDto(DA.ProblemParameterIntValue source) {
299      if (source == null) return null;
300      return new DT.ProblemParameterIntValue { ProblemParameterId = source.ProblemParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = source.Value };
301    }
302    public static DA.ProblemParameterIntValue ToEntity(DT.ProblemParameterIntValue source) {
303      if (source == null) return null;
304      return new DA.ProblemParameterIntValue { ProblemParameterId = source.ProblemParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = source.Value };
305    }
306    public static void ToEntity(DT.ProblemParameterIntValue source, DA.ProblemParameterIntValue target) {
307      if ((source != null) && (target != null)) {
308        target.ProblemParameterId = source.ProblemParameterId; target.ExperimentId = source.ExperimentId; target.DataTypeId = source.DataTypeId; target.Value = source.Value;
309      }
310    }
311    #endregion
312
313    #region ProblemParameterStringValue
314    public static DT.ProblemParameterStringValue ToDto(DA.ProblemParameterStringValue source) {
315      if (source == null) return null;
316      return new DT.ProblemParameterStringValue { ProblemParameterId = source.ProblemParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = source.Value };
317    }
318    public static DA.ProblemParameterStringValue ToEntity(DT.ProblemParameterStringValue source) {
319      if (source == null) return null;
320      return new DA.ProblemParameterStringValue { ProblemParameterId = source.ProblemParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = source.Value };
321    }
322    public static void ToEntity(DT.ProblemParameterStringValue source, DA.ProblemParameterStringValue target) {
323      if ((source != null) && (target != null)) {
324        target.ProblemParameterId = source.ProblemParameterId; target.ExperimentId = source.ExperimentId; target.DataTypeId = source.DataTypeId; target.Value = source.Value;
325      }
326    }
327    #endregion
328
329    #region Result
330    public static DT.Result ToDto(DA.Result source) {
331      if (source == null) return null;
332      return new DT.Result { Id = source.Id, Name = source.Name, Description = source.Description, Alias = source.Alias, AlgorithmId = source.AlgorithmId, DataTypeId = source.DataTypeId };
333    }
334    public static DA.Result ToEntity(DT.Result source) {
335      if (source == null) return null;
336      return new DA.Result { Id = source.Id, Name = source.Name, Description = source.Description, Alias = source.Alias, AlgorithmId = source.AlgorithmId, DataTypeId = source.DataTypeId };
337    }
338    public static void ToEntity(DT.Result source, DA.Result target) {
339      if ((source != null) && (target != null)) {
340        target.Id = source.Id; target.Name = source.Name; target.Description = source.Description; target.Alias = source.Alias; target.AlgorithmId = source.AlgorithmId; target.DataTypeId = source.DataTypeId;
341      }
342    }
343    #endregion
344
345    #region ResultBlobValue
346    public static DT.ResultBlobValue ToDto(DA.ResultBlobValue source) {
347      if (source == null) return null;
348      return new DT.ResultBlobValue { ResultId = source.ResultId, RunId = source.RunId, DataTypeId = source.DataTypeId, Value = source.Value.ToArray() };
349    }
350    public static DA.ResultBlobValue ToEntity(DT.ResultBlobValue source) {
351      if (source == null) return null;
352      return new DA.ResultBlobValue { ResultId = source.ResultId, RunId = source.RunId, DataTypeId = source.DataTypeId, Value = new Binary(source.Value) };
353    }
354    public static void ToEntity(DT.ResultBlobValue source, DA.ResultBlobValue target) {
355      if ((source != null) && (target != null)) {
356        target.ResultId = source.ResultId; target.RunId = source.RunId; target.DataTypeId = source.DataTypeId; target.Value = new Binary(source.Value);
357      }
358    }
359    #endregion
360
361    #region ResultBoolValue
362    public static DT.ResultBoolValue ToDto(DA.ResultBoolValue source) {
363      if (source == null) return null;
364      return new DT.ResultBoolValue { ResultId = source.ResultId, RunId = source.RunId, DataTypeId = source.DataTypeId, Value = source.Value };
365    }
366    public static DA.ResultBoolValue ToEntity(DT.ResultBoolValue source) {
367      if (source == null) return null;
368      return new DA.ResultBoolValue { ResultId = source.ResultId, RunId = source.RunId, DataTypeId = source.DataTypeId, Value = source.Value };
369    }
370    public static void ToEntity(DT.ResultBoolValue source, DA.ResultBoolValue target) {
371      if ((source != null) && (target != null)) {
372        target.ResultId = source.ResultId; target.RunId = source.RunId; target.DataTypeId = source.DataTypeId; target.Value = source.Value;
373      }
374    }
375    #endregion
376
377    #region ResultFloatValue
378    public static DT.ResultFloatValue ToDto(DA.ResultFloatValue source) {
379      if (source == null) return null;
380      return new DT.ResultFloatValue { ResultId = source.ResultId, RunId = source.RunId, DataTypeId = source.DataTypeId, Value = source.Value };
381    }
382    public static DA.ResultFloatValue ToEntity(DT.ResultFloatValue source) {
383      if (source == null) return null;
384      return new DA.ResultFloatValue { ResultId = source.ResultId, RunId = source.RunId, DataTypeId = source.DataTypeId, Value = source.Value };
385    }
386    public static void ToEntity(DT.ResultFloatValue source, DA.ResultFloatValue target) {
387      if ((source != null) && (target != null)) {
388        target.ResultId = source.ResultId; target.RunId = source.RunId; target.DataTypeId = source.DataTypeId; target.Value = source.Value;
389      }
390    }
391    #endregion
392
393    #region ResultIntValue
394    public static DT.ResultIntValue ToDto(DA.ResultIntValue source) {
395      if (source == null) return null;
396      return new DT.ResultIntValue { ResultId = source.ResultId, RunId = source.RunId, DataTypeId = source.DataTypeId, Value = source.Value };
397    }
398    public static DA.ResultIntValue ToEntity(DT.ResultIntValue source) {
399      if (source == null) return null;
400      return new DA.ResultIntValue { ResultId = source.ResultId, RunId = source.RunId, DataTypeId = source.DataTypeId, Value = source.Value };
401    }
402    public static void ToEntity(DT.ResultIntValue source, DA.ResultIntValue target) {
403      if ((source != null) && (target != null)) {
404        target.ResultId = source.ResultId; target.RunId = source.RunId; target.DataTypeId = source.DataTypeId; target.Value = source.Value;
405      }
406    }
407    #endregion
408
409    #region ResultStringValue
410    public static DT.ResultStringValue ToDto(DA.ResultStringValue source) {
411      if (source == null) return null;
412      return new DT.ResultStringValue { ResultId = source.ResultId, RunId = source.RunId, DataTypeId = source.DataTypeId, Value = source.Value };
413    }
414    public static DA.ResultStringValue ToEntity(DT.ResultStringValue source) {
415      if (source == null) return null;
416      return new DA.ResultStringValue { ResultId = source.ResultId, RunId = source.RunId, DataTypeId = source.DataTypeId, Value = source.Value };
417    }
418    public static void ToEntity(DT.ResultStringValue source, DA.ResultStringValue target) {
419      if ((source != null) && (target != null)) {
420        target.ResultId = source.ResultId; target.RunId = source.RunId; target.DataTypeId = source.DataTypeId; target.Value = source.Value;
421      }
422    }
423    #endregion
424
425    #region Experiment
426    public static DT.Experiment ToDto(DA.Experiment source) {
427      if (source == null) return null;
428      DT.Experiment target = new DT.Experiment { Id = source.Id, AlgorithmId = source.AlgorithmId, ProblemId = source.ProblemId };
429
430      List<DT.AlgorithmParameterValue> algorithmParameterValues = new List<DT.AlgorithmParameterValue>();
431      foreach (DA.AlgorithmParameterBlobValue value in source.AlgorithmParameterBlobValues)
432        algorithmParameterValues.Add(Convert.ToDto(value));
433      foreach (DA.AlgorithmParameterBoolValue value in source.AlgorithmParameterBoolValues)
434        algorithmParameterValues.Add(Convert.ToDto(value));
435      foreach (DA.AlgorithmParameterFloatValue value in source.AlgorithmParameterFloatValues)
436        algorithmParameterValues.Add(Convert.ToDto(value));
437      foreach (DA.AlgorithmParameterIntValue value in source.AlgorithmParameterIntValues)
438        algorithmParameterValues.Add(Convert.ToDto(value));
439      foreach (DA.AlgorithmParameterStringValue value in source.AlgorithmParameterStringValues)
440        algorithmParameterValues.Add(Convert.ToDto(value));
441      target.AlgorithmParameterValues = algorithmParameterValues.ToArray();
442
443      List<DT.ProblemParameterValue> problemParameterValues = new List<DT.ProblemParameterValue>();
444      foreach (DA.ProblemParameterBlobValue value in source.ProblemParameterBlobValues)
445        problemParameterValues.Add(Convert.ToDto(value));
446      foreach (DA.ProblemParameterBoolValue value in source.ProblemParameterBoolValues)
447        problemParameterValues.Add(Convert.ToDto(value));
448      foreach (DA.ProblemParameterFloatValue value in source.ProblemParameterFloatValues)
449        problemParameterValues.Add(Convert.ToDto(value));
450      foreach (DA.ProblemParameterIntValue value in source.ProblemParameterIntValues)
451        problemParameterValues.Add(Convert.ToDto(value));
452      foreach (DA.ProblemParameterStringValue value in source.ProblemParameterStringValues)
453        problemParameterValues.Add(Convert.ToDto(value));
454      target.ProblemParameterValues = problemParameterValues.ToArray();
455
456      return target;
457    }
458    public static DA.Experiment ToEntity(DT.Experiment source) {
459      if (source == null) return null;
460      DA.Experiment target = new DA.Experiment();
461      Convert.ToEntity(source, target);
462      return target;
463    }
464    public static void ToEntity(DT.Experiment source, DA.Experiment target) {
465      if ((source != null) && (target != null)) {
466        target.Id = source.Id; target.AlgorithmId = source.AlgorithmId; target.ProblemId = source.ProblemId;
467
468        foreach (DT.AlgorithmParameterBlobValue value in source.AlgorithmParameterValues.OfType<DT.AlgorithmParameterBlobValue>())
469          target.AlgorithmParameterBlobValues.Add(Convert.ToEntity(value));
470        foreach (DT.AlgorithmParameterBoolValue value in source.AlgorithmParameterValues.OfType<DT.AlgorithmParameterBoolValue>())
471          target.AlgorithmParameterBoolValues.Add(Convert.ToEntity(value));
472        foreach (DT.AlgorithmParameterFloatValue value in source.AlgorithmParameterValues.OfType<DT.AlgorithmParameterFloatValue>())
473          target.AlgorithmParameterFloatValues.Add(Convert.ToEntity(value));
474        foreach (DT.AlgorithmParameterIntValue value in source.AlgorithmParameterValues.OfType<DT.AlgorithmParameterIntValue>())
475          target.AlgorithmParameterIntValues.Add(Convert.ToEntity(value));
476        foreach (DT.AlgorithmParameterStringValue value in source.AlgorithmParameterValues.OfType<DT.AlgorithmParameterStringValue>())
477          target.AlgorithmParameterStringValues.Add(Convert.ToEntity(value));
478
479        foreach (DT.ProblemParameterBlobValue value in source.ProblemParameterValues.OfType<DT.ProblemParameterBlobValue>())
480          target.ProblemParameterBlobValues.Add(Convert.ToEntity(value));
481        foreach (DT.ProblemParameterBoolValue value in source.ProblemParameterValues.OfType<DT.ProblemParameterBoolValue>())
482          target.ProblemParameterBoolValues.Add(Convert.ToEntity(value));
483        foreach (DT.ProblemParameterFloatValue value in source.ProblemParameterValues.OfType<DT.ProblemParameterFloatValue>())
484          target.ProblemParameterFloatValues.Add(Convert.ToEntity(value));
485        foreach (DT.ProblemParameterIntValue value in source.ProblemParameterValues.OfType<DT.ProblemParameterIntValue>())
486          target.ProblemParameterIntValues.Add(Convert.ToEntity(value));
487        foreach (DT.ProblemParameterStringValue value in source.ProblemParameterValues.OfType<DT.ProblemParameterStringValue>())
488          target.ProblemParameterStringValues.Add(Convert.ToEntity(value));
489      }
490    }
491    #endregion
492
493    #region Run
494    public static DT.Run ToDto(DA.Run source) {
495      if (source == null) return null;
496      DT.Run target = new DT.Run { Id = source.Id, RandomSeed = source.RandomSeed, CreatedDate = source.CreatedDate, ExperimentId = source.ExperimentId, UserId = source.UserId, ClientId = source.ClientId };
497
498      List<DT.ResultValue> resultValues = new List<DT.ResultValue>();
499      foreach (DA.ResultBlobValue value in source.ResultBlobValues)
500        resultValues.Add(Convert.ToDto(value));
501      foreach (DA.ResultBoolValue value in source.ResultBoolValues)
502        resultValues.Add(Convert.ToDto(value));
503      foreach (DA.ResultFloatValue value in source.ResultFloatValues)
504        resultValues.Add(Convert.ToDto(value));
505      foreach (DA.ResultIntValue value in source.ResultIntValues)
506        resultValues.Add(Convert.ToDto(value));
507      foreach (DA.ResultStringValue value in source.ResultStringValues)
508        resultValues.Add(Convert.ToDto(value));
509      target.ResultValues = resultValues.ToArray();
510
511      return target;
512    }
513    public static DA.Run ToEntity(DT.Run source) {
514      if (source == null) return null;
515      DA.Run target = new DA.Run();
516      Convert.ToEntity(source, target);
517      return target;
518    }
519    public static void ToEntity(DT.Run source, DA.Run target) {
520      if ((source != null) && (target != null)) {
521        target.Id = source.Id; target.RandomSeed = source.RandomSeed; target.CreatedDate = source.CreatedDate; target.ExperimentId = source.ExperimentId; target.UserId = source.UserId; target.ClientId = source.ClientId;
522
523        foreach (DT.ResultBlobValue value in source.ResultValues.OfType<DT.ResultBlobValue>())
524          target.ResultBlobValues.Add(Convert.ToEntity(value));
525        foreach (DT.ResultBoolValue value in source.ResultValues.OfType<DT.ResultBoolValue>())
526          target.ResultBoolValues.Add(Convert.ToEntity(value));
527        foreach (DT.ResultFloatValue value in source.ResultValues.OfType<DT.ResultFloatValue>())
528          target.ResultFloatValues.Add(Convert.ToEntity(value));
529        foreach (DT.ResultIntValue value in source.ResultValues.OfType<DT.ResultIntValue>())
530          target.ResultIntValues.Add(Convert.ToEntity(value));
531        foreach (DT.ResultStringValue value in source.ResultValues.OfType<DT.ResultStringValue>())
532          target.ResultStringValues.Add(Convert.ToEntity(value));
533      }
534    }
535    #endregion
536  }
537}
Note: See TracBrowser for help on using the repository browser.