Changeset 13550 for trunk/sources/HeuristicLab.Clients.OKB/3.3/RunCreation
- Timestamp:
- 01/19/16 08:38:56 (9 years ago)
- Location:
- trunk/sources/HeuristicLab.Clients.OKB/3.3/RunCreation
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Clients.OKB/3.3/RunCreation/RunCreationClient.cs
r13534 r13550 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.IO; 24 25 using System.Linq; 25 26 using HeuristicLab.Clients.Common; 26 27 using HeuristicLab.Common; 27 28 using HeuristicLab.Core; 29 using HeuristicLab.Data; 30 using HeuristicLab.Persistence.Default.Xml; 28 31 29 32 namespace HeuristicLab.Clients.OKB.RunCreation { … … 114 117 #endregion 115 118 119 #region OKB-Item Conversion 120 public IItem ConvertToItem(Value value) { 121 if (value is BinaryValue) { 122 IItem item = null; 123 var binaryValue = (BinaryValue)value; 124 if (binaryValue.Value != null) { 125 using (var stream = new MemoryStream(binaryValue.Value)) { 126 try { 127 item = XmlParser.Deserialize<IItem>(stream); 128 } catch (Exception) { } 129 stream.Close(); 130 } 131 } 132 return item ?? new Data.StringValue(value.DataType.Name); 133 } else if (value is BoolValue) { 134 return new Data.BoolValue(((BoolValue)value).Value); 135 } else if (value is FloatValue) { 136 return new Data.DoubleValue(((FloatValue)value).Value); 137 } else if (value is PercentValue) { 138 return new Data.PercentValue(((PercentValue)value).Value); 139 } else if (value is DoubleValue) { 140 return new Data.DoubleValue(((DoubleValue)value).Value); 141 } else if (value is IntValue) { 142 return new Data.IntValue((int)((IntValue)value).Value); 143 } else if (value is LongValue) { 144 return new Data.IntValue((int)((LongValue)value).Value); 145 } else if (value is StringValue) { 146 return new Data.StringValue(((StringValue)value).Value); 147 } else if (value is TimeSpanValue) { 148 return new Data.TimeSpanValue(TimeSpan.FromSeconds((long)((TimeSpanValue)value).Value)); 149 } 150 return null; 151 } 152 153 public Value ConvertToValue(IItem item, string name) { 154 Value result = null; 155 if (item is ValueTypeValue<bool>) { 156 var boolValue = (ValueTypeValue<bool>)item; 157 result = new BoolValue() { Value = boolValue.Value }; 158 } else if (item is ValueTypeValue<int>) { 159 var intValue = (ValueTypeValue<int>)item; 160 result = new IntValue() { Value = intValue.Value }; 161 } else if (item is ValueTypeValue<long>) { 162 var longValue = (ValueTypeValue<long>)item; 163 result = new LongValue() { Value = longValue.Value }; 164 } else if (item is ValueTypeValue<float>) { 165 var floatValue = (ValueTypeValue<float>)item; 166 result = new FloatValue() { Value = floatValue.Value }; 167 } else if (item is ValueTypeValue<double>) { 168 var doubleValue = (ValueTypeValue<double>)item; 169 if (item is Data.PercentValue) result = new PercentValue() { Value = doubleValue.Value }; 170 else result = new DoubleValue() { Value = doubleValue.Value }; 171 } else if (item is ValueTypeValue<TimeSpan>) { 172 var timeSpanValue = (ValueTypeValue<TimeSpan>)item; 173 result = new TimeSpanValue() { Value = (long)timeSpanValue.Value.TotalSeconds }; 174 } else if (item is Data.StringValue) { 175 var stringValue = (Data.StringValue)item; 176 result = new StringValue() { Value = stringValue.Value }; 177 } 178 if (result == null) { 179 var binaryValue = new BinaryValue { 180 DataType = new DataType() { 181 Name = item.GetType().Name, 182 TypeName = item.GetType().AssemblyQualifiedName 183 } 184 }; 185 using (var memStream = new MemoryStream()) { 186 XmlGenerator.Serialize(item, memStream); 187 binaryValue.Value = memStream.ToArray(); 188 } 189 result = binaryValue; 190 } 191 result.Name = name; 192 return result; 193 } 194 #endregion 195 116 196 #region Events 117 197 public event EventHandler Refreshing; -
trunk/sources/HeuristicLab.Clients.OKB/3.3/RunCreation/ServiceClient/BoolValue.cs
r13534 r13550 24 24 namespace HeuristicLab.Clients.OKB.RunCreation { 25 25 public partial class BoolValue { 26 26 27 public BoolValue() { 27 28 DataType = new DataType() { … … 31 32 } 32 33 33 public override string ToString() {34 public override string GetValue() { 34 35 return Value.ToString(CultureInfo.CurrentCulture.NumberFormat); 35 36 } -
trunk/sources/HeuristicLab.Clients.OKB/3.3/RunCreation/ServiceClient/DoubleValue.cs
r13534 r13550 31 31 } 32 32 33 public override string ToString() {33 public override string GetValue() { 34 34 return Value.ToString(CultureInfo.CurrentCulture.NumberFormat); 35 35 } -
trunk/sources/HeuristicLab.Clients.OKB/3.3/RunCreation/ServiceClient/FloatValue.cs
r13534 r13550 31 31 } 32 32 33 public override string ToString() {33 public override string GetValue() { 34 34 return Value.ToString(CultureInfo.CurrentCulture.NumberFormat); 35 35 } -
trunk/sources/HeuristicLab.Clients.OKB/3.3/RunCreation/ServiceClient/IntValue.cs
r13534 r13550 31 31 } 32 32 33 public override string ToString() {33 public override string GetValue() { 34 34 return Value.ToString(CultureInfo.CurrentCulture.NumberFormat); 35 35 } -
trunk/sources/HeuristicLab.Clients.OKB/3.3/RunCreation/ServiceClient/LongValue.cs
r13534 r13550 31 31 } 32 32 33 public override string ToString() {33 public override string GetValue() { 34 34 return Value.ToString(CultureInfo.CurrentCulture.NumberFormat); 35 35 } -
trunk/sources/HeuristicLab.Clients.OKB/3.3/RunCreation/ServiceClient/PercentValue.cs
r13534 r13550 31 31 } 32 32 33 public override string ToString() {34 return (100 * Value).ToString(CultureInfo.CurrentCulture.NumberFormat) + "%";33 public override string GetValue() { 34 return Value.ToString(CultureInfo.CurrentCulture.NumberFormat); 35 35 } 36 36 } -
trunk/sources/HeuristicLab.Clients.OKB/3.3/RunCreation/ServiceClient/StringValue.cs
r13534 r13550 30 30 } 31 31 32 public override string ToString() {32 public override string GetValue() { 33 33 return Value; 34 34 } -
trunk/sources/HeuristicLab.Clients.OKB/3.3/RunCreation/ServiceClient/TimeSpanValue.cs
r13534 r13550 31 31 } 32 32 33 public override string ToString() {34 return Value.ToString(CultureInfo.CurrentCulture. DateTimeFormat);33 public override string GetValue() { 34 return Value.ToString(CultureInfo.CurrentCulture.NumberFormat); 35 35 } 36 36 } -
trunk/sources/HeuristicLab.Clients.OKB/3.3/RunCreation/ServiceClient/Value.cs
r13534 r13550 26 26 namespace HeuristicLab.Clients.OKB.RunCreation { 27 27 public partial class Value { 28 public virtual string GetValue() { 29 return string.Empty; 30 } 31 28 32 public static Value Create(string name, string strValue, string type) { 29 33 switch (type) {
Note: See TracChangeset
for help on using the changeset viewer.