Changeset 2676 for trunk/sources/HeuristicLab.Data/3.3
- Timestamp:
- 01/25/10 02:34:23 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Data/3.3
- Files:
-
- 1 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Data/3.3/BoolData.cs
r2669 r2676 41 41 } 42 42 43 #region IStringConvertibleData Members 44 bool IStringConvertibleData.Validate(string value) { 45 bool b; 46 return bool.TryParse(value, out b); 47 } 43 48 string IStringConvertibleData.GetValue() { 44 49 return Value.ToString(); … … 53 58 } 54 59 } 60 #endregion 55 61 } 56 62 } -
trunk/sources/HeuristicLab.Data/3.3/DateTimeData.cs
r2669 r2676 45 45 } 46 46 47 #region IStringConvertibleData Members 48 bool IStringConvertibleData.Validate(string value) { 49 DateTime d; 50 return DateTime.TryParse(value, out d); 51 } 47 52 string IStringConvertibleData.GetValue() { 48 53 return Value.ToString("o"); // round-trip format … … 57 62 } 58 63 } 64 #endregion 59 65 } 60 66 } -
trunk/sources/HeuristicLab.Data/3.3/DoubleData.cs
r2669 r2676 45 45 } 46 46 47 #region IStringConvertibleData Members 48 bool IStringConvertibleData.Validate(string value) { 49 double d; 50 return double.TryParse(value, out d); 51 } 47 52 string IStringConvertibleData.GetValue() { 48 53 return Value.ToString("r"); // round-trip format … … 57 62 } 58 63 } 64 #endregion 59 65 } 60 66 } -
trunk/sources/HeuristicLab.Data/3.3/HeuristicLab.Data-3.3.csproj
r2669 r2676 103 103 <SubType>Code</SubType> 104 104 </Compile> 105 <Compile Include="BoolArrayData.cs" /> 105 106 <Compile Include="IStringConvertibleArrayData.cs" /> 106 107 <Compile Include="ValueTypeArrayData.cs" /> -
trunk/sources/HeuristicLab.Data/3.3/IStringConvertibleArrayData.cs
r2669 r2676 31 31 int Length { get; set; } 32 32 33 bool Validate(string value); 33 34 string GetValue(int index); 34 35 bool SetValue(string value, int index); 35 36 36 event ChangedEventHandler Changed;37 37 event EventHandler<EventArgs<int>> ItemChanged; 38 event EventHandler Reset; 38 39 } 39 40 } -
trunk/sources/HeuristicLab.Data/3.3/IStringConvertibleData.cs
r2669 r2676 28 28 namespace HeuristicLab.Data { 29 29 public interface IStringConvertibleData { 30 bool Validate(string value); 30 31 string GetValue(); 31 32 bool SetValue(string value); -
trunk/sources/HeuristicLab.Data/3.3/IntArrayData.cs
r2669 r2676 24 24 using System.Text; 25 25 using System.Xml; 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; 27 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 34 35 public IntArrayData() : base() { } 35 36 public IntArrayData(int length) : base(length) { } 36 public IntArrayData(IntArrayData elements) : base(elements) { }37 37 public IntArrayData(int[] elements) : base(elements) { } 38 protected IntArrayData(IntArrayData elements) : base(elements) { } 38 39 39 40 public override IDeepCloneable Clone(Cloner cloner) { … … 43 44 } 44 45 46 #region IStringConvertibleArrayData Members 45 47 int IStringConvertibleArrayData.Length { 46 48 get { return Length; } 47 49 set { Length = value; } 50 } 51 bool IStringConvertibleArrayData.Validate(string value) { 52 int i; 53 return int.TryParse(value, out i); 48 54 } 49 55 string IStringConvertibleArrayData.GetValue(int index) { … … 59 65 } 60 66 } 67 event EventHandler<EventArgs<int>> IStringConvertibleArrayData.ItemChanged { 68 add { base.ItemChanged += value; } 69 remove { base.ItemChanged -= value; } 70 } 71 event EventHandler IStringConvertibleArrayData.Reset { 72 add { base.Reset += value; } 73 remove { base.Reset -= value; } 74 } 75 #endregion 61 76 } 62 77 } -
trunk/sources/HeuristicLab.Data/3.3/IntData.cs
r2669 r2676 41 41 } 42 42 43 #region IStringConvertibleData Members 44 bool IStringConvertibleData.Validate(string value) { 45 int i; 46 return int.TryParse(value, out i); 47 } 43 48 string IStringConvertibleData.GetValue() { 44 49 return Value.ToString(); … … 53 58 } 54 59 } 60 #endregion 55 61 } 56 62 } -
trunk/sources/HeuristicLab.Data/3.3/StringData.cs
r2669 r2676 63 63 } 64 64 65 #region IStringConvertibleData Members 66 bool IStringConvertibleData.Validate(string value) { 67 return true; 68 } 65 69 string IStringConvertibleData.GetValue() { 66 70 return Value; … … 70 74 return true; 71 75 } 76 #endregion 72 77 } 73 78 } -
trunk/sources/HeuristicLab.Data/3.3/TimeSpanData.cs
r2669 r2676 41 41 } 42 42 43 #region IStringConvertibleData Members 44 bool IStringConvertibleData.Validate(string value) { 45 TimeSpan t; 46 return TimeSpan.TryParse(value, out t); 47 } 43 48 string IStringConvertibleData.GetValue() { 44 49 return Value.ToString(); … … 53 58 } 54 59 } 60 #endregion 55 61 } 56 62 } -
trunk/sources/HeuristicLab.Data/3.3/ValueTypeArrayData.cs
r2669 r2676 41 41 Array.Copy(array, newArray, Math.Min(value, array.Length)); 42 42 array = newArray; 43 On Changed();43 OnReset(); 44 44 } 45 45 } … … 60 60 array = new T[length]; 61 61 } 62 public ValueTypeArrayData(ValueTypeArrayData<T> elements) {63 if (elements == null) throw new ArgumentNullException();64 array = (T[])elements.array.Clone();65 }66 62 public ValueTypeArrayData(T[] elements) { 67 63 if (elements == null) throw new ArgumentNullException(); 68 64 array = (T[])elements.Clone(); 65 } 66 protected ValueTypeArrayData(ValueTypeArrayData<T> elements) { 67 if (elements == null) throw new ArgumentNullException(); 68 array = (T[])elements.array.Clone(); 69 69 } 70 70 … … 91 91 } 92 92 93 p ublicevent EventHandler<EventArgs<int>> ItemChanged;94 pr otected virtualvoid OnItemChanged(int index) {93 protected event EventHandler<EventArgs<int>> ItemChanged; 94 private void OnItemChanged(int index) { 95 95 if (ItemChanged != null) 96 96 ItemChanged(this, new EventArgs<int>(index)); 97 97 OnChanged(); 98 98 } 99 protected event EventHandler Reset; 100 private void OnReset() { 101 if (Reset != null) 102 Reset(this, EventArgs.Empty); 103 OnChanged(); 104 } 99 105 } 100 106 }
Note: See TracChangeset
for help on using the changeset viewer.