Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/21/10 05:10:12 (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:
4 added
12 deleted
5 edited

Legend:

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

    r2526 r2665  
    2828
    2929namespace HeuristicLab.Data {
    30   /// <summary>
    31   /// Class to represent boolean values.
    32   /// </summary>
    3330  [EmptyStorableClass]
    34   public class BoolData : ObjectData {
    35     /// <summary>
    36     /// Gets or sets the boolean value.
    37     /// </summary>
    38     /// <remarks>Uses property <see cref="ObjectData.Data"/>
    39     /// of base class <see cref="ObjectData"/>. No own data storage present.</remarks>
    40     public new bool Data {
    41       get { return (bool)base.Data; }
    42       set { base.Data = value; }
     31  [Item("Boolean", "Represents a boolean value.")]
     32  [Creatable("Test")]
     33  public sealed class BoolData : ValueTypeData<bool>, IStringConvertibleData {
     34    public BoolData() : base() { }
     35    public BoolData(bool value)
     36      : base() {
     37      Value = value;
    4338    }
    4439
    45     /// <summary>
    46     /// Initializes a new instance of <see cref="BoolData"/> with default value <c>false</c>.
    47     /// </summary>
    48     public BoolData() {
    49       Data = false;
    50     }
    51     /// <summary>
    52     /// Initializes a new instance of <see cref="BoolData"/> with the boolean value <paramref name="data"/>.
    53     /// </summary>
    54     /// <param name="data">The boolean value to assign.</param>
    55     public BoolData(bool data) {
    56       Data = data;
     40    public override IDeepCloneable Clone(Cloner cloner) {
     41      BoolData clone = new BoolData(Value);
     42      cloner.RegisterClonedObject(this, clone);
     43      return clone;
    5744    }
    5845
    59     /// <summary>
    60     /// Clones the current instance.
    61     /// </summary>
    62     /// <remarks>The cloned instance is added to the <paramref name="dictionary"/>.</remarks>
    63     /// <param name="clonedObjects">Dictionary of all already cloned objects.</param>
    64     /// <returns>The cloned instance as <see cref="BoolData"/>.</returns>
    65     public override IItem Clone(ICloner cloner) {
    66       BoolData clone = new BoolData();
    67       cloner.RegisterClonedObject(this, clone);
    68       clone.Data = Data;
    69       return clone;
     46    string IStringConvertibleData.GetValue() {
     47      return Value.ToString();
     48    }
     49    bool IStringConvertibleData.SetValue(string value) {
     50      bool b;
     51      if (bool.TryParse(value, out b)) {
     52        Value = b;
     53        return true;
     54      } else {
     55        return false;
     56      }
    7057    }
    7158  }
  • trunk/sources/HeuristicLab.Data/3.3/DoubleData.cs

    r2526 r2665  
    2525using System.Xml;
    2626using HeuristicLab.Core;
    27 using System.Globalization;
    2827using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2928
    3029namespace HeuristicLab.Data {
    31   /// <summary>
    32   /// Class to represent double values.
    33   /// </summary>
    3430  [EmptyStorableClass]
    35   public class DoubleData : ObjectData {
    36     /// <summary>
    37     /// Gets or sets the double value.
    38     /// </summary>
    39     /// <remarks>Uses property <see cref="ObjectData.Data"/> of base class <see cref="ObjectData"></see>.
    40     /// No own data storage present.</remarks>
    41     public new double Data {
    42       get { return (double)base.Data; }
    43       set { base.Data = value; }
     31  [Item("Double", "Represents a double value.")]
     32  [Creatable("Test")]
     33  public sealed class DoubleData : ValueTypeData<double>, IStringConvertibleData {
     34    public DoubleData() : base() { }
     35    public DoubleData(double value)
     36      : base() {
     37      Value = value;
    4438    }
    4539
    46     /// <summary>
    47     /// Initializes a new instance of <see cref="DoubleData"/> with default value <c>0.0</c>.
    48     /// </summary>
    49     public DoubleData() {
    50       Data = 0.0;
    51     }
    52     /// <summary>
    53     /// Initializes a new instance of <see cref="DoubleData"/>.
    54     /// <note type="caution"> No CopyConstructor! <paramref name="data"/> is not copied!</note>
    55     /// </summary>
    56     /// <param name="data">The double value the instance should represent.</param>
    57     public DoubleData(double data) {
    58       Data = data;
     40    public override IDeepCloneable Clone(Cloner cloner) {
     41      DoubleData clone = new DoubleData(Value);
     42      cloner.RegisterClonedObject(this, clone);
     43      return clone;
    5944    }
    6045
    61     /// <summary>
    62     /// Clones the current instance and adds it to the dictionary <paramref name="clonedObjects"/>.
    63     /// </summary>
    64     /// <param name="clonedObjects">Dictionary of all already cloned objects.</param>
    65     /// <returns>The cloned instance as <see cref="DoubleData"/>.</returns>
    66     public override IItem Clone(ICloner cloner) {
    67       DoubleData clone = new DoubleData();
    68       cloner.RegisterClonedObject(this, clone);
    69       clone.Data = Data;
    70       return clone;
     46    string IStringConvertibleData.GetValue() {
     47      return Value.ToString();
     48    }
     49    bool IStringConvertibleData.SetValue(string value) {
     50      double d;
     51      if (double.TryParse(value, out d)) {
     52        Value = d;
     53        return true;
     54      } else {
     55        return false;
     56      }
    7157    }
    7258  }
  • trunk/sources/HeuristicLab.Data/3.3/HeuristicLab.Data-3.3.csproj

    r2663 r2665  
    100100  </ItemGroup>
    101101  <ItemGroup>
     102    <Compile Include="BoolData.cs">
     103      <SubType>Code</SubType>
     104    </Compile>
     105    <Compile Include="ReferenceTypeData.cs" />
     106    <Compile Include="StringData.cs">
     107      <SubType>Code</SubType>
     108    </Compile>
     109    <Compile Include="TimeSpanData.cs" />
     110    <Compile Include="DateTimeData.cs" />
     111    <Compile Include="DoubleData.cs">
     112      <SubType>Code</SubType>
     113    </Compile>
     114    <Compile Include="IStringConvertibleData.cs" />
    102115    <Compile Include="ValueTypeData.cs">
    103116      <SubType>Code</SubType>
  • trunk/sources/HeuristicLab.Data/3.3/IntData.cs

    r2663 r2665  
    2929namespace HeuristicLab.Data {
    3030  [EmptyStorableClass]
    31   [Item("Int Data", "Represents an integer value.")]
     31  [Item("Integer", "Represents an integer value.")]
    3232  [Creatable("Test")]
    33   public sealed class IntData : ValueTypeData<int> {
     33  public sealed class IntData : ValueTypeData<int>, IStringConvertibleData {
    3434    public IntData() : base() { }
    3535    public IntData(int value)
     
    4343      return clone;
    4444    }
     45
     46    string IStringConvertibleData.GetValue() {
     47      return Value.ToString();
     48    }
     49    bool IStringConvertibleData.SetValue(string value) {
     50      int i;
     51      if (int.TryParse(value, out i)) {
     52        Value = i;
     53        return true;
     54      } else {
     55        return false;
     56      }
     57    }
    4558  }
    4659}
  • trunk/sources/HeuristicLab.Data/3.3/StringData.cs

    r2526 r2665  
    2828
    2929namespace HeuristicLab.Data {
    30   /// <summary>
    31   /// The representation of a string.
    32   /// </summary>
    3330  [EmptyStorableClass]
    34   public class StringData : ObjectData {
    35     /// <summary>
    36     /// Gets or sets the string value.
    37     /// </summary>
    38     /// <remarks>Uses property <see cref="ObjectData.Data"/> of base class <see cref="ObjectData"/>.
    39     /// No own data storage present.</remarks>
    40     public new string Data {
    41       get { return (string)base.Data; }
    42       set { base.Data = value; }
     31  [Item("String", "Represents a string.")]
     32  [Creatable("Test")]
     33  public sealed class StringData : ReferenceTypeData<string>, IStringConvertibleData {
     34    public StringData() : base() {
     35      Value = string.Empty;
     36    }
     37    public StringData(string value)
     38      : base() {
     39      Value = value;
    4340    }
    4441
    45     /// <summary>
    46     /// Initializes a new instance of <see cref="StringData"/>
    47     /// with the name of the type of the current instance as default value.
    48     /// </summary>
    49     public StringData() {
    50       Data = this.GetType().Name;
    51     }
    52     /// <summary>
    53     /// Initializes a new instance of <see cref="StringData"/> with the specified <paramref name="data"/>.
    54     /// </summary>
    55     /// <param name="data">The string value the current instance should represent.</param>
    56     public StringData(string data) {
    57       Data = data;
    58     }
    59 
    60     /// <summary>
    61     /// Clones the current instance.
    62     /// </summary>
    63     /// <remarks>The current instance is added to the dictionary <paramref name="clonedObjects"/>.</remarks>
    64     /// <param name="clonedObjects">A dictionary of all already cloned objects.</param>
    65     /// <returns>The coned instance as <see cref="StringData"/>.</returns>
    66     public override IItem Clone(ICloner cloner) {
    67       StringData clone = new StringData();
     42    public override IDeepCloneable Clone(Cloner cloner) {
     43      StringData clone = new StringData(Value);
    6844      cloner.RegisterClonedObject(this, clone);
    69       clone.Data = Data;
    7045      return clone;
    7146    }
    7247
    73     /// <summary>
    74     /// The string representation of the current instance.
    75     /// </summary>
    76     /// <returns>The string value.</returns>
    77     public override string ToString() {
    78       return Data;
     48    string IStringConvertibleData.GetValue() {
     49      return Value;
     50    }
     51    bool IStringConvertibleData.SetValue(string value) {
     52      Value = value != null ? value : string.Empty;
     53      return true;
    7954    }
    8055  }
Note: See TracChangeset for help on using the changeset viewer.