- Timestamp:
- 01/15/16 12:13:51 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Services.OKB/3.3/RunCreation/Convert.cs
r13501 r13511 70 70 } 71 71 72 public static DA.CharacteristicValue ToEntity(DT.Value source, DA.OKBDataContext okb, DA.Problem problem, string characteristicName, DA.CharacteristicType type) { 73 if (okb == null || problem == null || string.IsNullOrEmpty(characteristicName) || source == null) throw new ArgumentNullException(); 72 public static DT.Value ToDto(DA.CharacteristicValue source) { 73 if (source == null) return null; 74 if (source.Characteristic.Type == DA.CharacteristicType.Bool) { 75 return new DT.BoolValue { Name = source.Characteristic.Name, DataType = Convert.ToDto(source.DataType), Value = source.BoolValue.GetValueOrDefault() }; 76 } else if (source.Characteristic.Type == DA.CharacteristicType.Int) { 77 return new DT.IntValue { Name = source.Characteristic.Name, DataType = Convert.ToDto(source.DataType), Value = source.IntValue.GetValueOrDefault() }; 78 } else if (source.Characteristic.Type == DA.CharacteristicType.TimeSpan) { 79 return new DT.TimeSpanValue { Name = source.Characteristic.Name, DataType = Convert.ToDto(source.DataType), Value = source.LongValue.GetValueOrDefault() }; 80 } else if (source.Characteristic.Type == DA.CharacteristicType.Long) { 81 return new DT.LongValue { Name = source.Characteristic.Name, DataType = Convert.ToDto(source.DataType), Value = source.LongValue.GetValueOrDefault() }; 82 } else if (source.Characteristic.Type == DA.CharacteristicType.Float) { 83 return new DT.FloatValue { Name = source.Characteristic.Name, DataType = Convert.ToDto(source.DataType), Value = source.FloatValue.GetValueOrDefault() }; 84 } else if (source.Characteristic.Type == DA.CharacteristicType.Double) { 85 return new DT.DoubleValue { Name = source.Characteristic.Name, DataType = Convert.ToDto(source.DataType), Value = source.DoubleValue.GetValueOrDefault() }; 86 } else if (source.Characteristic.Type == DA.CharacteristicType.Percent) { 87 return new DT.PercentValue { Name = source.Characteristic.Name, DataType = Convert.ToDto(source.DataType), Value = source.DoubleValue.GetValueOrDefault() }; 88 } else if (source.Characteristic.Type == DA.CharacteristicType.String) { 89 return new DT.StringValue { Name = source.Characteristic.Name, DataType = Convert.ToDto(source.DataType), Value = source.StringValue }; 90 } else { 91 throw new ArgumentException("Unknown characteristic type.", "source"); 92 } 93 } 94 95 public static DA.CharacteristicValue ToEntity(DT.Value source, DA.OKBDataContext okb, DA.Problem problem, DA.CharacteristicType type) { 96 if (okb == null || problem == null || source == null || string.IsNullOrEmpty(source.Name)) throw new ArgumentNullException(); 74 97 var entity = new DA.CharacteristicValue(); 75 98 entity.Problem = problem; 76 99 entity.DataType = Convert.ToEntity(source.DataType, okb); 77 entity.Characteristic = Convert.ToEntity( characteristicName, type, okb);100 entity.Characteristic = Convert.ToEntity(source.Name, type, okb); 78 101 if (source is DT.BoolValue) { 79 102 entity.BoolValue = ((DT.BoolValue)source).Value;
Note: See TracChangeset
for help on using the changeset viewer.