Changeset 2796 for trunk/sources/HeuristicLab.Parameters
- Timestamp:
- 02/15/10 05:26:02 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Parameters/3.3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Parameters/3.3/SubScopesLookupParameter.cs
r2793 r2796 33 33 /// </summary> 34 34 [Item("SubScopesLookupParameter<T>", "A generic parameter representing instances of type T which are collected from or written to the sub-scopes of the current scope.")] 35 public class SubScopesLookupParameter<T> : Parameter, ILookupParameter<T> where T : class, IItem { 36 [Storable] 37 private string actualName; 38 public string ActualName { 39 get { return actualName; } 40 set { 41 if (value == null) throw new ArgumentNullException(); 42 if (!actualName.Equals(value)) { 43 actualName = value; 44 OnActualNameChanged(); 45 } 46 } 47 } 48 49 public new ItemArray<T> ActualValue { 50 get { return (ItemArray<T>)GetActualValue(); } 51 set { SetActualValue(value); } 52 } 53 54 public SubScopesLookupParameter() 55 : base("Anonymous", typeof(ItemArray<T>)) { 56 actualName = Name; 57 } 58 public SubScopesLookupParameter(string name) 59 : base(name, typeof(ItemArray<T>)) { 60 actualName = Name; 61 } 62 public SubScopesLookupParameter(string name, string description) 63 : base(name, description, typeof(ItemArray<T>)) { 64 actualName = Name; 65 } 66 67 public override IDeepCloneable Clone(Cloner cloner) { 68 SubScopesLookupParameter<T> clone = (SubScopesLookupParameter<T>)base.Clone(cloner); 69 clone.actualName = actualName; 70 return clone; 71 } 72 73 public override string ToString() { 74 return string.Format("{0}: {1} ({2})", Name, ActualName, DataType.Name); 75 } 35 public class SubScopesLookupParameter<T> : LookupParameter<ItemArray<T>> where T : class, IItem { 36 public SubScopesLookupParameter() : base() { } 37 public SubScopesLookupParameter(string name) : base(name) { } 38 public SubScopesLookupParameter(string name, string description) : base(name, description) { } 76 39 77 40 protected override IItem GetActualValue() { … … 115 78 } 116 79 } 117 118 public event EventHandler ActualNameChanged;119 private void OnActualNameChanged() {120 if (ActualNameChanged != null)121 ActualNameChanged(this, EventArgs.Empty);122 OnChanged();123 }124 80 } 125 81 } -
trunk/sources/HeuristicLab.Parameters/3.3/ValueLookupParameter.cs
r2793 r2796 47 47 } 48 48 } 49 IItem IValueParameter.Value { 50 get { return Value; } 51 set { 52 T val = value as T; 53 if (val == null) 54 throw new InvalidOperationException( 55 string.Format("Type mismatch. Value is not a \"{0}\".", 56 typeof(T).GetPrettyName()) 57 ); 58 Value = val; 59 } 60 } 49 61 50 62 public ValueLookupParameter() -
trunk/sources/HeuristicLab.Parameters/3.3/ValueParameter.cs
r2793 r2796 47 47 } 48 48 } 49 public new T ActualValue {49 IItem IValueParameter.Value { 50 50 get { return Value; } 51 set { Value = value; } 51 set { 52 T val = value as T; 53 if (val == null) 54 throw new InvalidOperationException( 55 string.Format("Type mismatch. Value is not a \"{0}\".", 56 typeof(T).GetPrettyName()) 57 ); 58 Value = val; 59 } 52 60 } 53 61 … … 84 92 } 85 93 protected override void SetActualValue(IItem value) { 86 T val = value as T; 87 if (val == null) 88 throw new InvalidOperationException( 89 string.Format("Type mismatch. Value is not a \"{0}\".", 90 typeof(T).GetPrettyName()) 91 ); 92 Value = val; 94 ((IValueParameter)this).Value = value; 93 95 } 94 96
Note: See TracChangeset
for help on using the changeset viewer.