Changeset 3407 for trunk/sources/HeuristicLab.Core
- Timestamp:
- 04/19/10 03:28:16 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core/3.3/OperatorGraph.cs
r3386 r3407 90 90 protected OperatorGraph(bool deserializing) : base(deserializing) { } 91 91 92 //mkommend: IMP ROTANT DO NOT REMOVE THIS PRIVATE EVENT92 //mkommend: IMPORTANT DO NOT REMOVE THIS PRIVATE EVENT 93 93 //needed to register OperatorGraph events in GraphVisualizationInfo 94 94 public event EventHandler DeserializationFinished; … … 144 144 var opParams = from o in Operators 145 145 from p in o.Parameters 146 where p is IValueParameter<IOperator> 147 where (((IValueParameter<IOperator>)p).Value != null) && (((IValueParameter<IOperator>)p).Value == op) 148 select (IValueParameter<IOperator>)p; 149 foreach (IValueParameter<IOperator> opParam in opParams) 146 where p is IValueParameter 147 where typeof(IOperator).IsAssignableFrom(((IValueParameter)p).DataType) 148 where (((IValueParameter)p).Value != null) && (((IValueParameter)p).Value == op) 149 select (IValueParameter)p; 150 foreach (IValueParameter opParam in opParams) 150 151 opParam.Value = null; 151 152 } 152 153 private void AddParameter(IParameter param) { 153 IValueParameter <IOperator> opParam = param as IValueParameter<IOperator>;154 if ( opParam != null) {155 RegisterOperatorParameterEvents( opParam);156 if ( opParam.Value != null) Operators.Add(opParam.Value);154 IValueParameter valueParam = param as IValueParameter; 155 if ((valueParam != null) && (typeof(IOperator).IsAssignableFrom(valueParam.DataType))) { 156 RegisterOperatorParameterEvents(valueParam); 157 if (valueParam.Value != null) Operators.Add((IOperator)valueParam.Value); 157 158 } 158 159 } 159 160 private void RemoveParameter(IParameter param) { 160 IValueParameter <IOperator> opParam = param as IValueParameter<IOperator>;161 if ( opParam != null) {162 DeregisterOperatorParameterEvents( opParam);161 IValueParameter valueParam = param as IValueParameter; 162 if ((valueParam != null) && (typeof(IOperator).IsAssignableFrom(valueParam.DataType))) { 163 DeregisterOperatorParameterEvents(valueParam); 163 164 } 164 165 } … … 171 172 foreach (IOperator op in operators) { 172 173 RegisterOperatorEvents(op); 173 foreach (IParameter param in op.Parameters) { 174 IValueParameter<IOperator> opParam = param as IValueParameter<IOperator>; 175 if (opParam != null) RegisterOperatorParameterEvents(opParam); 176 } 174 var opParams = from p in op.Parameters 175 where p is IValueParameter 176 where typeof(IOperator).IsAssignableFrom(((IValueParameter)p).DataType) 177 select (IValueParameter)p; 178 foreach (IValueParameter opParam in opParams) 179 RegisterOperatorParameterEvents(opParam); 177 180 } 178 181 } … … 190 193 op.Parameters.CollectionReset -= new CollectionItemsChangedEventHandler<IParameter>(Parameters_CollectionReset); 191 194 } 192 private void RegisterOperatorParameterEvents(IValueParameter <IOperator>opParam) {195 private void RegisterOperatorParameterEvents(IValueParameter opParam) { 193 196 opParam.ValueChanged += new EventHandler(opParam_ValueChanged); 194 197 } 195 private void DeregisterOperatorParameterEvents(IValueParameter <IOperator>opParam) {198 private void DeregisterOperatorParameterEvents(IValueParameter opParam) { 196 199 opParam.ValueChanged -= new EventHandler(opParam_ValueChanged); 197 200 } … … 234 237 } 235 238 private void opParam_ValueChanged(object sender, EventArgs e) { 236 IValueParameter <IOperator> opParam = (IValueParameter<IOperator>)sender;237 if (opParam.Value != null) Operators.Add( opParam.Value);239 IValueParameter opParam = (IValueParameter)sender; 240 if (opParam.Value != null) Operators.Add((IOperator)opParam.Value); 238 241 } 239 242 #endregion
Note: See TracChangeset
for help on using the changeset viewer.