Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/22/10 03:29:02 (15 years ago)
Author:
swagner
Message:

Continued work on adapting and refactoring HeuristicLab.Data according to the changes in HeuristicLab.Core (#95)

Location:
trunk/sources/HeuristicLab.Data/3.3
Files:
2 added
13 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Data/3.3/BoolData.cs

    r2665 r2669  
    3333  public sealed class BoolData : ValueTypeData<bool>, IStringConvertibleData {
    3434    public BoolData() : base() { }
    35     public BoolData(bool value)
    36       : base() {
    37       Value = value;
    38     }
     35    public BoolData(bool value) : base(value) { }
    3936
    4037    public override IDeepCloneable Clone(Cloner cloner) {
  • trunk/sources/HeuristicLab.Data/3.3/DateTimeData.cs

    r2665 r2669  
    3333  public sealed class DateTimeData : ValueTypeData<DateTime>, IStringConvertibleData {
    3434    public DateTimeData() : base() { }
    35     public DateTimeData(DateTime value)
    36       : base() {
    37       Value = value;
    38     }
     35    public DateTimeData(DateTime value) : base(value) { }
    3936
    4037    public override IDeepCloneable Clone(Cloner cloner) {
     
    4441    }
    4542
     43    public override string ToString() {
     44      return Value.ToString("o");  // round-trip format
     45    }
     46
    4647    string IStringConvertibleData.GetValue() {
    47       return Value.ToString();
     48      return Value.ToString("o");  // round-trip format
    4849    }
    4950    bool IStringConvertibleData.SetValue(string value) {
  • trunk/sources/HeuristicLab.Data/3.3/DoubleData.cs

    r2665 r2669  
    3333  public sealed class DoubleData : ValueTypeData<double>, IStringConvertibleData {
    3434    public DoubleData() : base() { }
    35     public DoubleData(double value)
    36       : base() {
    37       Value = value;
    38     }
     35    public DoubleData(double value) : base(value) { }
    3936
    4037    public override IDeepCloneable Clone(Cloner cloner) {
     
    4441    }
    4542
     43    public override string ToString() {
     44      return Value.ToString("r");  // round-trip format
     45    }
     46
    4647    string IStringConvertibleData.GetValue() {
    47       return Value.ToString();
     48      return Value.ToString("r");  // round-trip format
    4849    }
    4950    bool IStringConvertibleData.SetValue(string value) {
  • trunk/sources/HeuristicLab.Data/3.3/HeuristicLab.Data-3.3.csproj

    r2665 r2669  
    103103      <SubType>Code</SubType>
    104104    </Compile>
    105     <Compile Include="ReferenceTypeData.cs" />
     105    <Compile Include="IStringConvertibleArrayData.cs" />
     106    <Compile Include="ValueTypeArrayData.cs" />
     107    <Compile Include="IntArrayData.cs" />
    106108    <Compile Include="StringData.cs">
    107109      <SubType>Code</SubType>
     
    126128      <Project>{0E27A536-1C4A-4624-A65E-DC4F4F23E3E1}</Project>
    127129      <Name>HeuristicLab.Common.Resources-3.2</Name>
     130    </ProjectReference>
     131    <ProjectReference Include="..\..\HeuristicLab.Common\3.2\HeuristicLab.Common-3.2.csproj">
     132      <Project>{1FC004FC-59AF-4249-B1B6-FF25873A20E4}</Project>
     133      <Name>HeuristicLab.Common-3.2</Name>
    128134    </ProjectReference>
    129135    <ProjectReference Include="..\..\HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj">
  • trunk/sources/HeuristicLab.Data/3.3/HeuristicLabDataPlugin.cs

    r2663 r2669  
    3131  [Plugin("HeuristicLab.Data-3.3", "")]
    3232  [PluginFile("HeuristicLab.Data-3.3.dll", PluginFileType.Assembly)]
     33  [PluginDependency("HeuristicLab.Common-3.2")]
    3334  [PluginDependency("HeuristicLab.Common.Resources-3.2")]
    3435  [PluginDependency("HeuristicLab.Core-3.3")]
  • trunk/sources/HeuristicLab.Data/3.3/IStringConvertibleData.cs

    r2665 r2669  
    2424using System.Text;
    2525using System.Xml;
     26using HeuristicLab.Core;
    2627
    2728namespace HeuristicLab.Data {
     
    3031    bool SetValue(string value);
    3132
    32     event EventHandler ValueChanged;
     33    event ChangedEventHandler Changed;
    3334  }
    3435}
  • trunk/sources/HeuristicLab.Data/3.3/IntArrayData.cs

    r2520 r2669  
    2525using System.Xml;
    2626using HeuristicLab.Core;
    27 using System.Globalization;
    2827using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2928
    3029namespace HeuristicLab.Data {
    31   /// <summary>
    32   /// The representation of an array of integer values.
    33   /// </summary>
    3430  [EmptyStorableClass]
    35   public class IntArrayData : ArrayDataBase {
    36     /// <summary>
    37     /// Gets or sets the int elements of the array.
    38     /// </summary>
    39     /// <remarks>Uses property <see cref="ArrayDataBase.Data"/> of base class <see cref="ArrayDataBase"/>.
    40     /// No own data storage present.</remarks>
    41     public new int[] Data {
    42       get { return (int[])base.Data; }
    43       set { base.Data = value; }
     31  [Item("IntArrayData", "Represents an array of integer values.")]
     32  [Creatable("Test")]
     33  public sealed class IntArrayData : ValueTypeArrayData<int>, IStringConvertibleArrayData {
     34    public IntArrayData() : base() { }
     35    public IntArrayData(int length) : base(length) { }
     36    public IntArrayData(IntArrayData elements) : base(elements) { }
     37    public IntArrayData(int[] elements) : base(elements) { }
     38
     39    public override IDeepCloneable Clone(Cloner cloner) {
     40      IntArrayData clone = new IntArrayData(this);
     41      cloner.RegisterClonedObject(this, clone);
     42      return clone;
    4443    }
    4544
    46     /// <summary>
    47     /// Initializes a new instance of <see cref="IntArrayData"/>.
    48     /// </summary>
    49     public IntArrayData() {
    50       Data = new int[0];
     45    int IStringConvertibleArrayData.Length {
     46      get { return Length; }
     47      set { Length = value; }
    5148    }
    52     /// <summary>
    53     /// Initializes a new instance of <see cref="IntArrayData"/>.
    54     /// <note type="caution"> No CopyConstructor! <paramref name="data"/> is not copied!</note>
    55     /// </summary>
    56     /// <param name="data">The array of integers to represent.</param>
    57     public IntArrayData(int[] data) {
    58       Data = data;
     49    string IStringConvertibleArrayData.GetValue(int index) {
     50      return this[index].ToString();
    5951    }
    60 
    61     /// <summary>
    62     /// The string representation of the array, formatted according to the given <paramref name="format"/>.
    63     /// </summary>
    64     /// <param name="format">The <see cref="NumberFormatInfo"></see> the single int values
    65     /// should be formatted accordingly.</param>
    66     /// <returns>The elements of the array as string, each element separated by a semicolon
    67     /// and formatted according to the parameter <paramref name="format"/>.</returns>
    68     private string ToString(NumberFormatInfo format) {
    69       StringBuilder builder = new StringBuilder();
    70       for (int i = 0; i < Data.Length; i++) {
    71         builder.Append(";");
    72         builder.Append(Data[i].ToString(format));
     52    bool IStringConvertibleArrayData.SetValue(string value, int index) {
     53      int i;
     54      if (int.TryParse(value, out i)) {
     55        this[index] = i;
     56        return true;
     57      } else {
     58        return false;
    7359      }
    74       if (builder.Length > 0) builder.Remove(0, 1);
    75       return builder.ToString();
    7660    }
    7761  }
  • trunk/sources/HeuristicLab.Data/3.3/IntData.cs

    r2665 r2669  
    3333  public sealed class IntData : ValueTypeData<int>, IStringConvertibleData {
    3434    public IntData() : base() { }
    35     public IntData(int value)
    36       : base() {
    37       Value = value;
    38     }
     35    public IntData(int value) : base(value) { }
    3936
    4037    public override IDeepCloneable Clone(Cloner cloner) {
  • trunk/sources/HeuristicLab.Data/3.3/StringData.cs

    r2665 r2669  
    3131  [Item("String", "Represents a string.")]
    3232  [Creatable("Test")]
    33   public sealed class StringData : ReferenceTypeData<string>, IStringConvertibleData {
    34     public StringData() : base() {
    35       Value = string.Empty;
     33  public sealed class StringData : Item, IStringConvertibleData {
     34    [Storable]
     35    private string value;
     36    public string Value {
     37      get { return value; }
     38      set {
     39        if (value != this.value) {
     40          if ((value != null) || (this.value != string.Empty)) {
     41            this.value = value != null ? value : string.Empty;
     42            OnChanged();
     43          }
     44        }
     45      }
    3646    }
    37     public StringData(string value)
    38       : base() {
    39       Value = value;
     47
     48    public StringData() {
     49      this.value = string.Empty;
     50    }
     51    public StringData(string value) {
     52      this.value = value != null ? value : string.Empty;
    4053    }
    4154
     
    4457      cloner.RegisterClonedObject(this, clone);
    4558      return clone;
     59    }
     60
     61    public override string ToString() {
     62      return value;
    4663    }
    4764
  • trunk/sources/HeuristicLab.Data/3.3/TimeSpanData.cs

    r2665 r2669  
    3333  public sealed class TimeSpanData : ValueTypeData<TimeSpan>, IStringConvertibleData {
    3434    public TimeSpanData() : base() { }
    35     public TimeSpanData(TimeSpan value)
    36       : base() {
    37       Value = value;
    38     }
     35    public TimeSpanData(TimeSpan value) : base(value) { }
    3936
    4037    public override IDeepCloneable Clone(Cloner cloner) {
  • trunk/sources/HeuristicLab.Data/3.3/ValueTypeData.cs

    r2664 r2669  
    3737        if (!value.Equals(this.value)) {
    3838          this.value = value;
    39           OnValueChanged();
     39          OnChanged();
    4040        }
    4141      }
     
    4343
    4444    public ValueTypeData() {
    45       value = default(T);
     45      this.value = default(T);
     46    }
     47    public ValueTypeData(T value) {
     48      this.value = value;
    4649    }
    4750
     
    5558      return value.ToString();
    5659    }
    57 
    58     public event EventHandler ValueChanged;
    59     protected virtual void OnValueChanged() {
    60       if (ValueChanged != null)
    61         ValueChanged(this, EventArgs.Empty);
    62       OnChanged();
    63     }
    6460  }
    6561}
Note: See TracChangeset for help on using the changeset viewer.