Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/TypeValue.cs @ 7101

Last change on this file since 7101 was 5313, checked in by cneumuel, 13 years ago

#1215

  • changed AlgorithType and ProblemType to actually be types not objects. this eliminates redundant views for MetaOptimizationProblem
  • import algorithm for MetaOptimizationProblem
  • nicer dialog for combination creation
  • fixed iconimage for ParameterConfigurations
  • fixed ValidValues
File size: 2.0 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using HeuristicLab.Core;
6using HeuristicLab.Data;
7using System.Drawing;
8using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
9using HeuristicLab.Common;
10
11namespace HeuristicLab.Problems.MetaOptimization {
12  [Item("TypeValue", "Represents a type.")]
13  [StorableClass]
14  public class TypeValue : Item {
15    public override Image ItemImage {
16      get { return HeuristicLab.Common.Resources.VSImageLibrary.Field; }
17    }
18
19    [Storable]
20    protected Type value;
21    public virtual Type Value {
22      get { return value; }
23      set {
24        if (ReadOnly) throw new NotSupportedException("Value cannot be set. TypeValue is read-only.");
25        if (!value.Equals(this.value)) {
26          this.value = value;
27          OnValueChanged();
28        }
29      }
30    }
31
32    [Storable]
33    protected bool readOnly;
34    public virtual bool ReadOnly {
35      get { return readOnly; }
36    }
37
38    public TypeValue() : base() {
39      this.readOnly = false;
40    }
41    public TypeValue(Type value) : base() {
42      this.Value = value;
43      this.readOnly = false;
44    }
45    [StorableConstructor]
46    protected TypeValue(bool deserializing) : base(deserializing) { }
47    protected TypeValue(TypeValue original, Cloner cloner)
48      : base(original, cloner) {
49      this.value = original.value;
50      this.readOnly = original.readOnly;
51    }
52    public override IDeepCloneable Clone(Cloner cloner) {
53      return new TypeValue(this, cloner);
54    }
55
56    public virtual TypeValue AsReadOnly() {
57      TypeValue readOnlyValueTypeValue = (TypeValue)this.Clone();
58      readOnlyValueTypeValue.readOnly = true;
59      return readOnlyValueTypeValue;
60    }
61
62    public override string ToString() {
63      return value.Name;
64    }
65
66    public event EventHandler ValueChanged;
67    protected virtual void OnValueChanged() {
68      if (ValueChanged != null)
69        ValueChanged(this, EventArgs.Empty);
70      OnToStringChanged();
71    }
72  }
73}
Note: See TracBrowser for help on using the repository browser.