Changeset 2715
- Timestamp:
- 01/29/10 04:15:45 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core/3.3/Interfaces/IOperatorParameter.cs
r2653 r2715 30 30 IOperator Value { get; set; } 31 31 32 new IOperator GetValue(ExecutionContext context);33 34 32 event EventHandler ActualNameChanged; 35 33 event EventHandler ValueChanged; -
trunk/sources/HeuristicLab.Operators/3.3/Counter.cs
r2714 r2715 50 50 51 51 public override ExecutionContextCollection Apply(ExecutionContext context) { 52 IntData value = Value.GetValue(context);53 IntData increment = Increment.GetValue(context);52 IntData value = (IntData)Value.GetValue(context); 53 IntData increment = (IntData)Increment.GetValue(context); 54 54 value.Value += increment.Value; 55 55 return base.Apply(context); -
trunk/sources/HeuristicLab.Operators/3.3/StandardOperator.cs
r2714 r2715 46 46 47 47 public override ExecutionContextCollection Apply(ExecutionContext context) { 48 IOperator successor = Successor.GetValue(context);48 IOperator successor = (IOperator)Successor.GetValue(context); 49 49 if (successor != null) 50 50 return new ExecutionContextCollection(new ExecutionContext(context.Parent, successor, context.Scope)); -
trunk/sources/HeuristicLab.Parameters.Views/3.3/ItemParameterView.Designer.cs
r2714 r2715 21 21 22 22 namespace HeuristicLab.Parameters.Views { 23 partial class ItemParameterView {23 partial class ItemParameterView<T> { 24 24 /// <summary> 25 25 /// Required designer variable. -
trunk/sources/HeuristicLab.Parameters.Views/3.3/ItemParameterView.cs
r2714 r2715 35 35 /// The visual representation of a <see cref="Parameter"/>. 36 36 /// </summary> 37 [Content(typeof(ItemParameter ), true)]38 public partial class ItemParameterView : ParameterView{37 [Content(typeof(ItemParameter<>), true)] 38 public partial class ItemParameterView<T> : ParameterView where T : class, IItem { 39 39 protected TypeSelectorDialog typeSelectorDialog; 40 40 … … 44 44 /// <remarks>Uses property <see cref="ViewBase.Item"/> of base class <see cref="ViewBase"/>. 45 45 /// No own data storage present.</remarks> 46 public new ItemParameter Content {47 get { return (ItemParameter )base.Content; }46 public new ItemParameter<T> Content { 47 get { return (ItemParameter<T>)base.Content; } 48 48 set { base.Content = value; } 49 49 } … … 61 61 /// <remarks>Calls <see cref="VariableView()"/>.</remarks> 62 62 /// <param name="variable">The variable to represent visually.</param> 63 public ItemParameterView(ItemParameter parameter)63 public ItemParameterView(ItemParameter<T> parameter) 64 64 : this() { 65 65 Content = parameter; … … 134 134 typeSelectorDialog.TypeSelector.Configure(Content.DataType, false, false); 135 135 if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) 136 Content.Value = ( IItem)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();136 Content.Value = (T)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType(); 137 137 } 138 138 protected virtual void clearValueButton_Click(object sender, EventArgs e) { … … 152 152 protected virtual void valuePanel_DragDrop(object sender, DragEventArgs e) { 153 153 if (e.Effect != DragDropEffects.None) { 154 IItem item = e.Data.GetData("Value") as IItem;155 if ((e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) item = ( IItem)item.Clone();154 T item = e.Data.GetData("Value") as T; 155 if ((e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) item = (T)item.Clone(); 156 156 Content.Value = item; 157 157 } -
trunk/sources/HeuristicLab.Parameters/3.3/ItemParameter.cs
r2714 r2715 31 31 /// Represents a parameter. 32 32 /// </summary> 33 [Item("ItemParameter", "A parameter which represents an IItem.")] 34 [Creatable("Test")] 35 public class ItemParameter : Parameter { 33 [Item("ItemParameter<T>", "A generic parameter which represents an instance of type T.")] 34 public class ItemParameter<T> : Parameter where T : class, IItem { 36 35 [Storable] 37 36 private string actualName; … … 47 46 } 48 47 49 private IItemvalue;48 private T value; 50 49 [Storable] 51 public IItemValue {50 public T Value { 52 51 get { return this.value; } 53 52 set { … … 63 62 64 63 public ItemParameter() 65 : base("Anonymous", null, typeof( IItem)) {64 : base("Anonymous", null, typeof(T)) { 66 65 actualName = Name; 67 66 Value = null; 68 67 } 69 p rotected ItemParameter(string name, string description, Type dataType)70 : base(name, description, dataType) {68 public ItemParameter(string name, string description) 69 : base(name, description, typeof(T)) { 71 70 this.actualName = Name; 72 71 this.Value = null; 73 72 } 74 public ItemParameter(string name, string description) 75 : base(name, description, typeof(IItem)) { 76 this.actualName = Name; 77 this.Value = null; 78 } 79 public ItemParameter(string name, string description, IItem value) 80 : base(name, description, typeof(IItem)) { 73 public ItemParameter(string name, string description, T value) 74 : base(name, description, typeof(T)) { 81 75 this.actualName = Name; 82 76 this.Value = value; … … 84 78 85 79 public override IItem GetValue(ExecutionContext context) { 86 ItemParameter param = this;80 ItemParameter<T> param = this; 87 81 ExecutionContext current = context; 88 82 string actualName = null; … … 94 88 current = current.Parent; 95 89 if (current != null) 96 param = (ItemParameter )current.Operator.Parameters[actualName];90 param = (ItemParameter<T>)current.Operator.Parameters[actualName]; 97 91 else 98 92 param = null; … … 106 100 107 101 public override IDeepCloneable Clone(Cloner cloner) { 108 ItemParameter clone = (ItemParameter)base.Clone(cloner);102 ItemParameter<T> clone = (ItemParameter<T>)base.Clone(cloner); 109 103 clone.actualName = actualName; 110 clone.Value = ( IItem)cloner.Clone(value);104 clone.Value = (T)cloner.Clone(value); 111 105 return clone; 112 106 } … … 133 127 } 134 128 } 135 136 [Item("ItemParameter<T>", "A generic parameter which represents an instance of type T.")]137 [EmptyStorableClass]138 public class ItemParameter<T> : ItemParameter where T : class, IItem {139 public new T Value {140 get { return (T)base.Value; }141 set { base.Value = value; }142 }143 144 public ItemParameter()145 : base("Anonymous", null, typeof(T)) {146 Value = null;147 }148 public ItemParameter(string name, string description)149 : base(name, description, typeof(T)) {150 this.Value = null;151 }152 public ItemParameter(string name, string description, T value)153 : base(name, description, typeof(T)) {154 this.Value = value;155 }156 157 public new T GetValue(ExecutionContext context) {158 return (T)base.GetValue(context);159 }160 }161 129 }
Note: See TracChangeset
for help on using the changeset viewer.