- Timestamp:
- 11/27/14 11:23:37 (10 years ago)
- Location:
- branches/Breadcrumbs
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Breadcrumbs
- Property svn:ignore
-
old new 8 8 FxCopResults.txt 9 9 Google.ProtocolBuffers-0.9.1.dll 10 Google.ProtocolBuffers-2.4.1.473.dll 10 11 HeuristicLab 3.3.5.1.ReSharper.user 11 12 HeuristicLab 3.3.6.0.ReSharper.user 12 13 HeuristicLab.4.5.resharper.user 13 14 HeuristicLab.ExtLibs.6.0.ReSharper.user 15 HeuristicLab.Scripting.Development 14 16 HeuristicLab.resharper.user 15 17 ProtoGen.exe … … 17 19 _ReSharper.HeuristicLab 18 20 _ReSharper.HeuristicLab 3.3 21 _ReSharper.HeuristicLab 3.3 Tests 19 22 _ReSharper.HeuristicLab.ExtLibs 20 23 bin 21 24 protoc.exe 22 _ReSharper.HeuristicLab 3.3 Tests23 Google.ProtocolBuffers-2.4.1.473.dll
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/Breadcrumbs/HeuristicLab.Data/3.3
- Property svn:mergeinfo changed
-
branches/Breadcrumbs/HeuristicLab.Data/3.3/PercentValue.cs
r9456 r11594 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 3Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 20 20 #endregion 21 21 22 using System; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; … … 28 29 [StorableClass] 29 30 public class PercentValue : DoubleValue { 31 [Storable(DefaultValue = false)] 32 private bool restrictToUnitInterval = false; 33 public bool RestrictToUnitInterval { 34 get { return restrictToUnitInterval; } 35 } 36 37 public override double Value { 38 get { return base.Value; } 39 set { 40 if (restrictToUnitInterval && (value < 0 || value > 1)) 41 throw new ArgumentException("Value must lie in the interval [0,1]."); 42 base.Value = value; 43 } 44 } 45 30 46 [StorableConstructor] 31 47 protected PercentValue(bool deserializing) : base(deserializing) { } 32 48 protected PercentValue(PercentValue original, Cloner cloner) 33 49 : base(original, cloner) { 50 restrictToUnitInterval = original.restrictToUnitInterval; 34 51 } 35 52 public PercentValue() : base() { } 36 53 public PercentValue(double value) : base(value) { } 54 55 public PercentValue(double value, bool restrictToUnitInterval) 56 : base() { 57 this.restrictToUnitInterval = restrictToUnitInterval; 58 if (restrictToUnitInterval && (value < 0 || value > 1)) 59 throw new ArgumentException("Value must lie in the interval [0,1]."); 60 this.value = value; 61 } 37 62 38 63 public override IDeepCloneable Clone(Cloner cloner) { … … 46 71 protected override bool Validate(string value, out string errorMessage) { 47 72 value = value.Replace("%", " "); 48 return base.Validate(value, out errorMessage); 73 bool valid = base.Validate(value, out errorMessage); 74 if (!restrictToUnitInterval || !valid) return valid; 75 76 double val = double.Parse(value); 77 if (val < 0 || val > 1) { 78 errorMessage = "Value must lie in the interval [0,1]."; 79 return false; 80 } 81 return true; 49 82 } 83 50 84 protected override string GetValue() { 51 85 return Value.ToString("#0.#################### %"); // percent format
Note: See TracChangeset
for help on using the changeset viewer.