Changeset 5843
- Timestamp:
- 03/28/11 17:22:36 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Parameters/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Parameters/3.3/FixedValueParameter.cs
r5809 r5843 31 31 [Item("FixedValueParameter", "A parameter whose value is defined in the parameter itself and cannot be set.")] 32 32 [StorableClass] 33 public class FixedValueParameter<T> : ValueParameter<T>, IFixedValueParameter<T> where T : class,IItem {33 public class FixedValueParameter<T> : ValueParameter<T>, IFixedValueParameter<T> where T : class,IItem, new() { 34 34 35 35 public override T Value { … … 44 44 protected FixedValueParameter(FixedValueParameter<T> original, Cloner cloner) : base(original, cloner) { } 45 45 46 public FixedValueParameter(string name) : base(name, default(T)) { } 47 public FixedValueParameter(string name, bool getsCollected) : base(name, default(T), getsCollected) { } 46 public FixedValueParameter() : base() { } 47 public FixedValueParameter(string name) : base(name) { } 48 public FixedValueParameter(string name, bool getsCollected) : base(name, getsCollected) { } 48 49 public FixedValueParameter(string name, T value) : base(name, value) { } 49 50 public FixedValueParameter(string name, T value, bool getsCollected) : base(name, value, getsCollected) { } 50 public FixedValueParameter(string name, string description) : base(name, description , default(T)) { }51 public FixedValueParameter(string name, string description, bool getsCollected) : base(name, description, default(T),getsCollected) { }51 public FixedValueParameter(string name, string description) : base(name, description) { } 52 public FixedValueParameter(string name, string description, bool getsCollected) : base(name, description, getsCollected) { } 52 53 public FixedValueParameter(string name, string description, T value) : base(name, description, value) { } 53 54 public FixedValueParameter(string name, string description, T value, bool getsCollected) : base(name, description, value, getsCollected) { } -
trunk/sources/HeuristicLab.Parameters/3.3/ValueParameter.cs
r5445 r5843 21 21 22 22 using System; 23 using System.Reflection; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; … … 43 44 protected ValueParameter(bool deserializing) : base(deserializing) { } 44 45 protected ValueParameter(ValueParameter<T> original, Cloner cloner) : base(original, cloner) { } 46 45 47 public ValueParameter() : base() { } 46 public ValueParameter(string name) : base(name) { }47 public ValueParameter(string name, bool getsCollected) : base(name, getsCollected) { }48 public ValueParameter(string name) : base(name) { base.Value = CreateDefaultValue(); } 49 public ValueParameter(string name, bool getsCollected) : base(name, getsCollected) { base.Value = CreateDefaultValue(); } 48 50 public ValueParameter(string name, T value) : base(name, value) { } 49 51 public ValueParameter(string name, T value, bool getsCollected) : base(name, value, getsCollected) { } 50 public ValueParameter(string name, string description) : base(name, description) { }51 public ValueParameter(string name, string description, bool getsCollected) : base(name, description, getsCollected) { }52 public ValueParameter(string name, string description) : base(name, description) { base.Value = CreateDefaultValue(); } 53 public ValueParameter(string name, string description, bool getsCollected) : base(name, description, getsCollected) { base.Value = CreateDefaultValue(); } 52 54 public ValueParameter(string name, string description, T value) : base(name, description, value) { } 53 55 public ValueParameter(string name, string description, T value, bool getsCollected) : base(name, description, value, getsCollected) { } 56 57 protected T CreateDefaultValue() { 58 ConstructorInfo defaultConstructor = typeof(T).GetConstructor(Type.EmptyTypes); 59 if (defaultConstructor != null) 60 return (T)defaultConstructor.Invoke(new object[0]); 61 return null; 62 } 54 63 55 64 public override IDeepCloneable Clone(Cloner cloner) {
Note: See TracChangeset
for help on using the changeset viewer.