Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/29/19 15:00:56 (5 years ago)
Author:
mkommend
Message:

#3005: Added readonly flag to all value parameters.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Parameters/3.3/OptionalConstrainedValueParameter.cs

    r16565 r16872  
    2222using System;
    2323using System.Drawing;
     24using HEAL.Attic;
    2425using HeuristicLab.Collections;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
    27 using HEAL.Attic;
    2828
    2929namespace HeuristicLab.Parameters {
     
    4040      }
    4141    }
    42      
     42
    4343    [Storable]
    4444    private ItemSet<T> validValues;
     
    5252      get { return this.value; }
    5353      set {
     54        if (ReadOnly) throw new InvalidOperationException("Cannot set the value of a readonly parameter.");
    5455        if (value != this.value) {
    5556          if ((value != null) && !validValues.Contains(value)) throw new ArgumentException("Invalid value.");
     
    7475    }
    7576
     77    [Storable(DefaultValue = false)]
     78    private bool readOnly;
     79    public bool ReadOnly {
     80      get { return readOnly; }
     81      set {
     82        if (value == readOnly) return;
     83        readOnly = value;
     84        OnReadOnlyChanged();
     85      }
     86    }
     87
    7688    [Storable(DefaultValue = true)]
    7789    private bool getsCollected;
     
    93105      validValues = cloner.Clone(original.validValues);
    94106      value = cloner.Clone(original.value);
     107      readOnly = original.readOnly;
    95108      getsCollected = original.getsCollected;
    96109      Initialize();
     
    99112      : base("Anonymous", typeof(T)) {
    100113      this.validValues = new ItemSet<T>();
     114      this.readOnly = false;
    101115      this.getsCollected = true;
    102116      Initialize();
     
    105119      : base(name, typeof(T)) {
    106120      this.validValues = new ItemSet<T>();
     121      this.readOnly = false;
    107122      this.getsCollected = true;
    108123      Initialize();
     
    111126      : base(name, typeof(T)) {
    112127      this.validValues = new ItemSet<T>();
     128      this.readOnly = false;
    113129      this.getsCollected = getsCollected;
    114130      Initialize();
     
    117133      : base(name, typeof(T)) {
    118134      this.validValues = validValues;
     135      this.readOnly = false;
    119136      this.getsCollected = true;
    120137      Initialize();
     
    123140      : base(name, typeof(T)) {
    124141      this.validValues = validValues;
     142      this.readOnly = false;
    125143      this.getsCollected = getsCollected;
    126144      Initialize();
     
    130148      this.validValues = validValues;
    131149      this.value = value;
     150      this.readOnly = false;
    132151      this.getsCollected = true;
    133152      Initialize();
     
    137156      this.validValues = validValues;
    138157      this.value = value;
     158      this.readOnly = false;
    139159      this.getsCollected = getsCollected;
    140160      Initialize();
     
    143163      : base(name, description, typeof(T)) {
    144164      this.validValues = new ItemSet<T>();
     165      this.readOnly = false;
    145166      this.getsCollected = true;
    146167      Initialize();
     
    149170      : base(name, description, typeof(T)) {
    150171      this.validValues = new ItemSet<T>();
     172      this.readOnly = false;
    151173      this.getsCollected = getsCollected;
    152174      Initialize();
     
    155177      : base(name, description, typeof(T)) {
    156178      this.validValues = validValues;
     179      this.readOnly = false;
    157180      this.getsCollected = true;
    158181      Initialize();
     
    161184      : base(name, description, typeof(T)) {
    162185      this.validValues = validValues;
     186      this.readOnly = false;
    163187      this.getsCollected = getsCollected;
    164188      Initialize();
     
    168192      this.validValues = validValues;
    169193      this.value = value;
     194      this.readOnly = false;
    170195      this.getsCollected = true;
    171196      Initialize();
     
    175200      this.validValues = validValues;
    176201      this.value = value;
     202      this.readOnly = false;
    177203      this.getsCollected = getsCollected;
    178204      Initialize();
     
    212238      OnToStringChanged();
    213239    }
     240    public event EventHandler ReadOnlyChanged;
     241    protected virtual void OnReadOnlyChanged() {
     242      EventHandler handler = ReadOnlyChanged;
     243      if (handler != null) handler(this, EventArgs.Empty);
     244    }
    214245    public event EventHandler GetsCollectedChanged;
    215246    protected virtual void OnGetsCollectedChanged() {
Note: See TracChangeset for help on using the changeset viewer.