#region License Information /* HeuristicLab * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using System.Collections.Generic; using System.Data.Linq; using System.Linq; using DA = HeuristicLab.Services.OKB.DataAccess; using DT = HeuristicLab.Services.OKB.DataTransfer; namespace HeuristicLab.Services.OKB { public static class Convert { #region Platform public static DT.Platform ToDto(DA.Platform source) { if (source == null) return null; return new DT.Platform { Id = source.Id, Name = source.Name, Description = source.Description }; } public static DA.Platform ToEntity(DT.Platform source) { if (source == null) return null; return new DA.Platform { Id = source.Id, Name = source.Name, Description = source.Description }; } public static void ToEntity(DT.Platform source, DA.Platform target) { if ((source != null) && (target != null)) { target.Id = source.Id; target.Name = source.Name; target.Description = source.Description; } } #endregion #region DataType public static DT.DataType ToDto(DA.DataType source) { if (source == null) return null; return new DT.DataType { Id = source.Id, Name = source.Name, TypeName = source.TypeName, SqlName = source.SqlName, PlatformId = source.PlatformId }; } public static DA.DataType ToEntity(DT.DataType source) { if (source == null) return null; return new DA.DataType { Id = source.Id, Name = source.Name, TypeName = source.TypeName, SqlName = source.SqlName, PlatformId = source.PlatformId }; } public static void ToEntity(DT.DataType source, DA.DataType target) { if ((source != null) && (target != null)) { target.Id = source.Id; target.Name = source.Name; target.TypeName = source.TypeName; target.SqlName = source.SqlName; target.PlatformId = source.PlatformId; } } #endregion #region AlgorithmClass public static DT.AlgorithmClass ToDto(DA.AlgorithmClass source) { if (source == null) return null; return new DT.AlgorithmClass { Id = source.Id, Name = source.Name, Description = source.Description }; } public static DA.AlgorithmClass ToEntity(DT.AlgorithmClass source) { if (source == null) return null; return new DA.AlgorithmClass { Id = source.Id, Name = source.Name, Description = source.Description }; } public static void ToEntity(DT.AlgorithmClass source, DA.AlgorithmClass target) { if ((source != null) && (target != null)) { target.Id = source.Id; target.Name = source.Name; target.Description = source.Description; } } #endregion #region Algorithm public static DT.Algorithm ToDto(DA.Algorithm source) { if (source == null) return null; return new DT.Algorithm { Id = source.Id, Name = source.Name, Description = source.Description, PlatformId = source.PlatformId, AlgorithmClassId = source.AlgorithmClassId }; } public static DA.Algorithm ToEntity(DT.Algorithm source) { if (source == null) return null; return new DA.Algorithm { Id = source.Id, Name = source.Name, Description = source.Description, PlatformId = source.PlatformId, AlgorithmClassId = source.AlgorithmClassId }; } public static void ToEntity(DT.Algorithm source, DA.Algorithm target) { if ((source != null) && (target != null)) { target.Id = source.Id; target.Name = source.Name; target.Description = source.Description; target.PlatformId = source.PlatformId; target.AlgorithmClassId = source.AlgorithmClassId; } } #endregion #region AlgorithmData public static DT.AlgorithmData ToDto(DA.AlgorithmData source) { if (source == null) return null; return new DT.AlgorithmData { AlgorithmId = source.AlgorithmId, DataTypeId = source.DataTypeId, Data = source.Data.ToArray() }; } public static DA.AlgorithmData ToEntity(DT.AlgorithmData source) { if (source == null) return null; return new DA.AlgorithmData { AlgorithmId = source.AlgorithmId, DataTypeId = source.DataTypeId, Data = new Binary(source.Data) }; } public static void ToEntity(DT.AlgorithmData source, DA.AlgorithmData target) { if ((source != null) && (target != null)) { target.AlgorithmId = source.AlgorithmId; target.DataTypeId = source.DataTypeId; target.Data = new Binary(source.Data); } } #endregion #region AlgorithmParameter public static DT.AlgorithmParameter ToDto(DA.AlgorithmParameter source) { if (source == null) return null; return new DT.AlgorithmParameter { Id = source.Id, Name = source.Name, Description = source.Description, Alias = source.Alias, AlgorithmId = source.AlgorithmId, DataTypeId = source.DataTypeId }; } public static DA.AlgorithmParameter ToEntity(DT.AlgorithmParameter source) { if (source == null) return null; return new DA.AlgorithmParameter { Id = source.Id, Name = source.Name, Description = source.Description, Alias = source.Alias, AlgorithmId = source.AlgorithmId, DataTypeId = source.DataTypeId }; } public static void ToEntity(DT.AlgorithmParameter source, DA.AlgorithmParameter target) { if ((source != null) && (target != null)) { target.Id = source.Id; target.Name = source.Name; target.Description = source.Description; target.Alias = source.Alias; target.AlgorithmId = source.AlgorithmId; target.DataTypeId = source.DataTypeId; } } #endregion #region AlgorithmParameterBlobValue public static DT.AlgorithmParameterBlobValue ToDto(DA.AlgorithmParameterBlobValue source) { if (source == null) return null; return new DT.AlgorithmParameterBlobValue { AlgorithmParameterId = source.AlgorithmParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = source.Value.ToArray() }; } public static DA.AlgorithmParameterBlobValue ToEntity(DT.AlgorithmParameterBlobValue source) { if (source == null) return null; return new DA.AlgorithmParameterBlobValue { AlgorithmParameterId = source.AlgorithmParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = new Binary(source.Value) }; } public static void ToEntity(DT.AlgorithmParameterBlobValue source, DA.AlgorithmParameterBlobValue target) { if ((source != null) && (target != null)) { target.AlgorithmParameterId = source.AlgorithmParameterId; target.ExperimentId = source.ExperimentId; target.DataTypeId = source.DataTypeId; target.Value = new Binary(source.Value); } } #endregion #region AlgorithmParameterBoolValue public static DT.AlgorithmParameterBoolValue ToDto(DA.AlgorithmParameterBoolValue source) { if (source == null) return null; return new DT.AlgorithmParameterBoolValue { AlgorithmParameterId = source.AlgorithmParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = source.Value }; } public static DA.AlgorithmParameterBoolValue ToEntity(DT.AlgorithmParameterBoolValue source) { if (source == null) return null; return new DA.AlgorithmParameterBoolValue { AlgorithmParameterId = source.AlgorithmParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = source.Value }; } public static void ToEntity(DT.AlgorithmParameterBoolValue source, DA.AlgorithmParameterBoolValue target) { if ((source != null) && (target != null)) { target.AlgorithmParameterId = source.AlgorithmParameterId; target.ExperimentId = source.ExperimentId; target.DataTypeId = source.DataTypeId; target.Value = source.Value; } } #endregion #region AlgorithmParameterFloatValue public static DT.AlgorithmParameterFloatValue ToDto(DA.AlgorithmParameterFloatValue source) { if (source == null) return null; return new DT.AlgorithmParameterFloatValue { AlgorithmParameterId = source.AlgorithmParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = source.Value }; } public static DA.AlgorithmParameterFloatValue ToEntity(DT.AlgorithmParameterFloatValue source) { if (source == null) return null; return new DA.AlgorithmParameterFloatValue { AlgorithmParameterId = source.AlgorithmParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = source.Value }; } public static void ToEntity(DT.AlgorithmParameterFloatValue source, DA.AlgorithmParameterFloatValue target) { if ((source != null) && (target != null)) { target.AlgorithmParameterId = source.AlgorithmParameterId; target.ExperimentId = source.ExperimentId; target.DataTypeId = source.DataTypeId; target.Value = source.Value; } } #endregion #region AlgorithmParameterIntValue public static DT.AlgorithmParameterIntValue ToDto(DA.AlgorithmParameterIntValue source) { if (source == null) return null; return new DT.AlgorithmParameterIntValue { AlgorithmParameterId = source.AlgorithmParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = source.Value }; } public static DA.AlgorithmParameterIntValue ToEntity(DT.AlgorithmParameterIntValue source) { if (source == null) return null; return new DA.AlgorithmParameterIntValue { AlgorithmParameterId = source.AlgorithmParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = source.Value }; } public static void ToEntity(DT.AlgorithmParameterIntValue source, DA.AlgorithmParameterIntValue target) { if ((source != null) && (target != null)) { target.AlgorithmParameterId = source.AlgorithmParameterId; target.ExperimentId = source.ExperimentId; target.DataTypeId = source.DataTypeId; target.Value = source.Value; } } #endregion #region AlgorithmParameterStringValue public static DT.AlgorithmParameterStringValue ToDto(DA.AlgorithmParameterStringValue source) { if (source == null) return null; return new DT.AlgorithmParameterStringValue { AlgorithmParameterId = source.AlgorithmParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = source.Value }; } public static DA.AlgorithmParameterStringValue ToEntity(DT.AlgorithmParameterStringValue source) { if (source == null) return null; return new DA.AlgorithmParameterStringValue { AlgorithmParameterId = source.AlgorithmParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = source.Value }; } public static void ToEntity(DT.AlgorithmParameterStringValue source, DA.AlgorithmParameterStringValue target) { if ((source != null) && (target != null)) { target.AlgorithmParameterId = source.AlgorithmParameterId; target.ExperimentId = source.ExperimentId; target.DataTypeId = source.DataTypeId; target.Value = source.Value; } } #endregion #region ProblemClass public static DT.ProblemClass ToDto(DA.ProblemClass source) { if (source == null) return null; return new DT.ProblemClass { Id = source.Id, Name = source.Name, Description = source.Description }; } public static DA.ProblemClass ToEntity(DT.ProblemClass source) { if (source == null) return null; return new DA.ProblemClass { Id = source.Id, Name = source.Name, Description = source.Description }; } public static void ToEntity(DT.ProblemClass source, DA.ProblemClass target) { if ((source != null) && (target != null)) { target.Id = source.Id; target.Name = source.Name; target.Description = source.Description; } } #endregion #region Problem public static DT.Problem ToDto(DA.Problem source) { if (source == null) return null; return new DT.Problem { Id = source.Id, Name = source.Name, Description = source.Description, PlatformId = source.PlatformId, ProblemClassId = source.ProblemClassId }; } public static DA.Problem ToEntity(DT.Problem source) { if (source == null) return null; return new DA.Problem { Id = source.Id, Name = source.Name, Description = source.Description, PlatformId = source.PlatformId, ProblemClassId = source.ProblemClassId }; } public static void ToEntity(DT.Problem source, DA.Problem target) { if ((source != null) && (target != null)) { target.Id = source.Id; target.Name = source.Name; target.Description = source.Description; target.PlatformId = source.PlatformId; target.ProblemClassId = source.ProblemClassId; } } #endregion #region ProblemData public static DT.ProblemData ToDto(DA.ProblemData source) { if (source == null) return null; return new DT.ProblemData { ProblemId = source.ProblemId, DataTypeId = source.DataTypeId, Data = source.Data.ToArray() }; } public static DA.ProblemData ToEntity(DT.ProblemData source) { if (source == null) return null; return new DA.ProblemData { ProblemId = source.ProblemId, DataTypeId = source.DataTypeId, Data = new Binary(source.Data) }; } public static void ToEntity(DT.ProblemData source, DA.ProblemData target) { if ((source != null) && (target != null)) { target.ProblemId = source.ProblemId; target.DataTypeId = source.DataTypeId; target.Data = new Binary(source.Data); } } #endregion #region ProblemParameter public static DT.ProblemParameter ToDto(DA.ProblemParameter source) { if (source == null) return null; return new DT.ProblemParameter { Id = source.Id, Name = source.Name, Description = source.Description, Alias = source.Alias, ProblemId = source.ProblemId, DataTypeId = source.DataTypeId }; } public static DA.ProblemParameter ToEntity(DT.ProblemParameter source) { if (source == null) return null; return new DA.ProblemParameter { Id = source.Id, Name = source.Name, Description = source.Description, Alias = source.Alias, ProblemId = source.ProblemId, DataTypeId = source.DataTypeId }; } public static void ToEntity(DT.ProblemParameter source, DA.ProblemParameter target) { if ((source != null) && (target != null)) { target.Id = source.Id; target.Name = source.Name; target.Description = source.Description; target.Alias = source.Alias; target.ProblemId = source.ProblemId; target.DataTypeId = source.DataTypeId; } } #endregion #region ProblemParameterBlobValue public static DT.ProblemParameterBlobValue ToDto(DA.ProblemParameterBlobValue source) { if (source == null) return null; return new DT.ProblemParameterBlobValue { ProblemParameterId = source.ProblemParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = source.Value.ToArray() }; } public static DA.ProblemParameterBlobValue ToEntity(DT.ProblemParameterBlobValue source) { if (source == null) return null; return new DA.ProblemParameterBlobValue { ProblemParameterId = source.ProblemParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = new Binary(source.Value) }; } public static void ToEntity(DT.ProblemParameterBlobValue source, DA.ProblemParameterBlobValue target) { if ((source != null) && (target != null)) { target.ProblemParameterId = source.ProblemParameterId; target.ExperimentId = source.ExperimentId; target.DataTypeId = source.DataTypeId; target.Value = new Binary(source.Value); } } #endregion #region ProblemParameterBoolValue public static DT.ProblemParameterBoolValue ToDto(DA.ProblemParameterBoolValue source) { if (source == null) return null; return new DT.ProblemParameterBoolValue { ProblemParameterId = source.ProblemParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = source.Value }; } public static DA.ProblemParameterBoolValue ToEntity(DT.ProblemParameterBoolValue source) { if (source == null) return null; return new DA.ProblemParameterBoolValue { ProblemParameterId = source.ProblemParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = source.Value }; } public static void ToEntity(DT.ProblemParameterBoolValue source, DA.ProblemParameterBoolValue target) { if ((source != null) && (target != null)) { target.ProblemParameterId = source.ProblemParameterId; target.ExperimentId = source.ExperimentId; target.DataTypeId = source.DataTypeId; target.Value = source.Value; } } #endregion #region ProblemParameterFloatValue public static DT.ProblemParameterFloatValue ToDto(DA.ProblemParameterFloatValue source) { if (source == null) return null; return new DT.ProblemParameterFloatValue { ProblemParameterId = source.ProblemParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = source.Value }; } public static DA.ProblemParameterFloatValue ToEntity(DT.ProblemParameterFloatValue source) { if (source == null) return null; return new DA.ProblemParameterFloatValue { ProblemParameterId = source.ProblemParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = source.Value }; } public static void ToEntity(DT.ProblemParameterFloatValue source, DA.ProblemParameterFloatValue target) { if ((source != null) && (target != null)) { target.ProblemParameterId = source.ProblemParameterId; target.ExperimentId = source.ExperimentId; target.DataTypeId = source.DataTypeId; target.Value = source.Value; } } #endregion #region ProblemParameterIntValue public static DT.ProblemParameterIntValue ToDto(DA.ProblemParameterIntValue source) { if (source == null) return null; return new DT.ProblemParameterIntValue { ProblemParameterId = source.ProblemParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = source.Value }; } public static DA.ProblemParameterIntValue ToEntity(DT.ProblemParameterIntValue source) { if (source == null) return null; return new DA.ProblemParameterIntValue { ProblemParameterId = source.ProblemParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = source.Value }; } public static void ToEntity(DT.ProblemParameterIntValue source, DA.ProblemParameterIntValue target) { if ((source != null) && (target != null)) { target.ProblemParameterId = source.ProblemParameterId; target.ExperimentId = source.ExperimentId; target.DataTypeId = source.DataTypeId; target.Value = source.Value; } } #endregion #region ProblemParameterStringValue public static DT.ProblemParameterStringValue ToDto(DA.ProblemParameterStringValue source) { if (source == null) return null; return new DT.ProblemParameterStringValue { ProblemParameterId = source.ProblemParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = source.Value }; } public static DA.ProblemParameterStringValue ToEntity(DT.ProblemParameterStringValue source) { if (source == null) return null; return new DA.ProblemParameterStringValue { ProblemParameterId = source.ProblemParameterId, ExperimentId = source.ExperimentId, DataTypeId = source.DataTypeId, Value = source.Value }; } public static void ToEntity(DT.ProblemParameterStringValue source, DA.ProblemParameterStringValue target) { if ((source != null) && (target != null)) { target.ProblemParameterId = source.ProblemParameterId; target.ExperimentId = source.ExperimentId; target.DataTypeId = source.DataTypeId; target.Value = source.Value; } } #endregion #region Result public static DT.Result ToDto(DA.Result source) { if (source == null) return null; return new DT.Result { Id = source.Id, Name = source.Name, Description = source.Description, Alias = source.Alias, AlgorithmId = source.AlgorithmId, DataTypeId = source.DataTypeId }; } public static DA.Result ToEntity(DT.Result source) { if (source == null) return null; return new DA.Result { Id = source.Id, Name = source.Name, Description = source.Description, Alias = source.Alias, AlgorithmId = source.AlgorithmId, DataTypeId = source.DataTypeId }; } public static void ToEntity(DT.Result source, DA.Result target) { if ((source != null) && (target != null)) { target.Id = source.Id; target.Name = source.Name; target.Description = source.Description; target.Alias = source.Alias; target.AlgorithmId = source.AlgorithmId; target.DataTypeId = source.DataTypeId; } } #endregion #region ResultBlobValue public static DT.ResultBlobValue ToDto(DA.ResultBlobValue source) { if (source == null) return null; return new DT.ResultBlobValue { ResultId = source.ResultId, RunId = source.RunId, DataTypeId = source.DataTypeId, Value = source.Value.ToArray() }; } public static DA.ResultBlobValue ToEntity(DT.ResultBlobValue source) { if (source == null) return null; return new DA.ResultBlobValue { ResultId = source.ResultId, RunId = source.RunId, DataTypeId = source.DataTypeId, Value = new Binary(source.Value) }; } public static void ToEntity(DT.ResultBlobValue source, DA.ResultBlobValue target) { if ((source != null) && (target != null)) { target.ResultId = source.ResultId; target.RunId = source.RunId; target.DataTypeId = source.DataTypeId; target.Value = new Binary(source.Value); } } #endregion #region ResultBoolValue public static DT.ResultBoolValue ToDto(DA.ResultBoolValue source) { if (source == null) return null; return new DT.ResultBoolValue { ResultId = source.ResultId, RunId = source.RunId, DataTypeId = source.DataTypeId, Value = source.Value }; } public static DA.ResultBoolValue ToEntity(DT.ResultBoolValue source) { if (source == null) return null; return new DA.ResultBoolValue { ResultId = source.ResultId, RunId = source.RunId, DataTypeId = source.DataTypeId, Value = source.Value }; } public static void ToEntity(DT.ResultBoolValue source, DA.ResultBoolValue target) { if ((source != null) && (target != null)) { target.ResultId = source.ResultId; target.RunId = source.RunId; target.DataTypeId = source.DataTypeId; target.Value = source.Value; } } #endregion #region ResultFloatValue public static DT.ResultFloatValue ToDto(DA.ResultFloatValue source) { if (source == null) return null; return new DT.ResultFloatValue { ResultId = source.ResultId, RunId = source.RunId, DataTypeId = source.DataTypeId, Value = source.Value }; } public static DA.ResultFloatValue ToEntity(DT.ResultFloatValue source) { if (source == null) return null; return new DA.ResultFloatValue { ResultId = source.ResultId, RunId = source.RunId, DataTypeId = source.DataTypeId, Value = source.Value }; } public static void ToEntity(DT.ResultFloatValue source, DA.ResultFloatValue target) { if ((source != null) && (target != null)) { target.ResultId = source.ResultId; target.RunId = source.RunId; target.DataTypeId = source.DataTypeId; target.Value = source.Value; } } #endregion #region ResultIntValue public static DT.ResultIntValue ToDto(DA.ResultIntValue source) { if (source == null) return null; return new DT.ResultIntValue { ResultId = source.ResultId, RunId = source.RunId, DataTypeId = source.DataTypeId, Value = source.Value }; } public static DA.ResultIntValue ToEntity(DT.ResultIntValue source) { if (source == null) return null; return new DA.ResultIntValue { ResultId = source.ResultId, RunId = source.RunId, DataTypeId = source.DataTypeId, Value = source.Value }; } public static void ToEntity(DT.ResultIntValue source, DA.ResultIntValue target) { if ((source != null) && (target != null)) { target.ResultId = source.ResultId; target.RunId = source.RunId; target.DataTypeId = source.DataTypeId; target.Value = source.Value; } } #endregion #region ResultStringValue public static DT.ResultStringValue ToDto(DA.ResultStringValue source) { if (source == null) return null; return new DT.ResultStringValue { ResultId = source.ResultId, RunId = source.RunId, DataTypeId = source.DataTypeId, Value = source.Value }; } public static DA.ResultStringValue ToEntity(DT.ResultStringValue source) { if (source == null) return null; return new DA.ResultStringValue { ResultId = source.ResultId, RunId = source.RunId, DataTypeId = source.DataTypeId, Value = source.Value }; } public static void ToEntity(DT.ResultStringValue source, DA.ResultStringValue target) { if ((source != null) && (target != null)) { target.ResultId = source.ResultId; target.RunId = source.RunId; target.DataTypeId = source.DataTypeId; target.Value = source.Value; } } #endregion #region Experiment public static DT.Experiment ToDto(DA.Experiment source) { if (source == null) return null; DT.Experiment target = new DT.Experiment { Id = source.Id, AlgorithmId = source.AlgorithmId, ProblemId = source.ProblemId }; List algorithmParameterValues = new List(); foreach (DA.AlgorithmParameterBlobValue value in source.AlgorithmParameterBlobValues) algorithmParameterValues.Add(Convert.ToDto(value)); foreach (DA.AlgorithmParameterBoolValue value in source.AlgorithmParameterBoolValues) algorithmParameterValues.Add(Convert.ToDto(value)); foreach (DA.AlgorithmParameterFloatValue value in source.AlgorithmParameterFloatValues) algorithmParameterValues.Add(Convert.ToDto(value)); foreach (DA.AlgorithmParameterIntValue value in source.AlgorithmParameterIntValues) algorithmParameterValues.Add(Convert.ToDto(value)); foreach (DA.AlgorithmParameterStringValue value in source.AlgorithmParameterStringValues) algorithmParameterValues.Add(Convert.ToDto(value)); target.AlgorithmParameterValues = algorithmParameterValues.ToArray(); List problemParameterValues = new List(); foreach (DA.ProblemParameterBlobValue value in source.ProblemParameterBlobValues) problemParameterValues.Add(Convert.ToDto(value)); foreach (DA.ProblemParameterBoolValue value in source.ProblemParameterBoolValues) problemParameterValues.Add(Convert.ToDto(value)); foreach (DA.ProblemParameterFloatValue value in source.ProblemParameterFloatValues) problemParameterValues.Add(Convert.ToDto(value)); foreach (DA.ProblemParameterIntValue value in source.ProblemParameterIntValues) problemParameterValues.Add(Convert.ToDto(value)); foreach (DA.ProblemParameterStringValue value in source.ProblemParameterStringValues) problemParameterValues.Add(Convert.ToDto(value)); target.ProblemParameterValues = problemParameterValues.ToArray(); return target; } public static DA.Experiment ToEntity(DT.Experiment source) { if (source == null) return null; DA.Experiment target = new DA.Experiment(); Convert.ToEntity(source, target); return target; } public static void ToEntity(DT.Experiment source, DA.Experiment target) { if ((source != null) && (target != null)) { target.Id = source.Id; target.AlgorithmId = source.AlgorithmId; target.ProblemId = source.ProblemId; foreach (DT.AlgorithmParameterBlobValue value in source.AlgorithmParameterValues.OfType()) target.AlgorithmParameterBlobValues.Add(Convert.ToEntity(value)); foreach (DT.AlgorithmParameterBoolValue value in source.AlgorithmParameterValues.OfType()) target.AlgorithmParameterBoolValues.Add(Convert.ToEntity(value)); foreach (DT.AlgorithmParameterFloatValue value in source.AlgorithmParameterValues.OfType()) target.AlgorithmParameterFloatValues.Add(Convert.ToEntity(value)); foreach (DT.AlgorithmParameterIntValue value in source.AlgorithmParameterValues.OfType()) target.AlgorithmParameterIntValues.Add(Convert.ToEntity(value)); foreach (DT.AlgorithmParameterStringValue value in source.AlgorithmParameterValues.OfType()) target.AlgorithmParameterStringValues.Add(Convert.ToEntity(value)); foreach (DT.ProblemParameterBlobValue value in source.ProblemParameterValues.OfType()) target.ProblemParameterBlobValues.Add(Convert.ToEntity(value)); foreach (DT.ProblemParameterBoolValue value in source.ProblemParameterValues.OfType()) target.ProblemParameterBoolValues.Add(Convert.ToEntity(value)); foreach (DT.ProblemParameterFloatValue value in source.ProblemParameterValues.OfType()) target.ProblemParameterFloatValues.Add(Convert.ToEntity(value)); foreach (DT.ProblemParameterIntValue value in source.ProblemParameterValues.OfType()) target.ProblemParameterIntValues.Add(Convert.ToEntity(value)); foreach (DT.ProblemParameterStringValue value in source.ProblemParameterValues.OfType()) target.ProblemParameterStringValues.Add(Convert.ToEntity(value)); } } #endregion #region Run public static DT.Run ToDto(DA.Run source) { if (source == null) return null; DT.Run target = new DT.Run { Id = source.Id, RandomSeed = source.RandomSeed, CreatedDate = source.CreatedDate, ExperimentId = source.ExperimentId, UserId = source.UserId, ClientId = source.ClientId }; List resultValues = new List(); foreach (DA.ResultBlobValue value in source.ResultBlobValues) resultValues.Add(Convert.ToDto(value)); foreach (DA.ResultBoolValue value in source.ResultBoolValues) resultValues.Add(Convert.ToDto(value)); foreach (DA.ResultFloatValue value in source.ResultFloatValues) resultValues.Add(Convert.ToDto(value)); foreach (DA.ResultIntValue value in source.ResultIntValues) resultValues.Add(Convert.ToDto(value)); foreach (DA.ResultStringValue value in source.ResultStringValues) resultValues.Add(Convert.ToDto(value)); target.ResultValues = resultValues.ToArray(); return target; } public static DA.Run ToEntity(DT.Run source) { if (source == null) return null; DA.Run target = new DA.Run(); Convert.ToEntity(source, target); return target; } public static void ToEntity(DT.Run source, DA.Run target) { if ((source != null) && (target != null)) { target.Id = source.Id; target.RandomSeed = source.RandomSeed; target.CreatedDate = source.CreatedDate; target.ExperimentId = source.ExperimentId; target.UserId = source.UserId; target.ClientId = source.ClientId; foreach (DT.ResultBlobValue value in source.ResultValues.OfType()) target.ResultBlobValues.Add(Convert.ToEntity(value)); foreach (DT.ResultBoolValue value in source.ResultValues.OfType()) target.ResultBoolValues.Add(Convert.ToEntity(value)); foreach (DT.ResultFloatValue value in source.ResultValues.OfType()) target.ResultFloatValues.Add(Convert.ToEntity(value)); foreach (DT.ResultIntValue value in source.ResultValues.OfType()) target.ResultIntValues.Add(Convert.ToEntity(value)); foreach (DT.ResultStringValue value in source.ResultValues.OfType()) target.ResultStringValues.Add(Convert.ToEntity(value)); } } #endregion } }