Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/21/10 05:10:12 (14 years ago)
Author:
swagner
Message:

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

File:
1 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  }
Note: See TracChangeset for help on using the changeset viewer.