- Timestamp:
- 10/29/10 18:50:00 (14 years ago)
- Location:
- branches/CloningRefactoring
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/CloningRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/Moves/AdditiveMoveGenerator.cs
r4672 r4673 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Data; … … 26 27 using HeuristicLab.Parameters; 27 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 using HeuristicLab.Common;29 29 30 30 namespace HeuristicLab.Encodings.RealVectorEncoding { … … 63 63 } 64 64 65 public override IDeepCloneable Clone(Cloner cloner) {66 return new AdditiveMoveGenerator(this, cloner);67 }68 69 65 public override IOperation Apply() { 70 66 RealVector vector = RealVectorParameter.ActualValue; -
branches/CloningRefactoring/HeuristicLab.Operators.Programmable/3.3/ProgrammableOperator.cs
r4477 r4673 160 160 161 161 #region Construction & Initialization 162 [StorableConstructor] 163 protected ProgrammableOperator(bool deserializing) : base(deserializing) { } 164 [StorableHook(HookType.AfterDeserialization)] 165 private void AfterDeserialization() { 166 RegisterEvents(); 167 } 168 169 protected ProgrammableOperator(ProgrammableOperator original, Cloner cloner) 170 : base(original, cloner) { 171 code = original.Code; 172 executeMethod = original.executeMethod; 173 Assemblies = original.Assemblies.ToDictionary(kvp => kvp.Key, kvp => kvp.Value); 174 namespaces = original.namespaces; 175 CompilationUnitCode = original.CompilationUnitCode; 176 CompileErrors = original.CompileErrors; 177 RegisterEvents(); 178 } 179 public override IDeepCloneable Clone(Cloner cloner) { 180 return new ProgrammableOperator(this, cloner); 181 } 162 182 163 183 public ProgrammableOperator() { … … 171 191 } 172 192 173 [StorableHook(HookType.AfterDeserialization)] 193 174 194 private void RegisterEvents() { 175 195 Parameters.ItemsAdded += Parameters_Changed; … … 185 205 protected void OnSignatureChanged() { 186 206 EventHandler handler = SignatureChanged; 187 if (handler != null) 188 handler(this, EventArgs.Empty); 207 if (handler != null) handler(this, EventArgs.Empty); 189 208 } 190 209 … … 426 445 public event EventHandler CodeChanged; 427 446 protected virtual void OnCodeChanged() { 428 if (CodeChanged != null)429 CodeChanged(this, new EventArgs());447 EventHandler handler = CodeChanged; 448 if (handler != null) handler(this, EventArgs.Empty); 430 449 } 431 450 432 451 #endregion 433 434 #region Cloning435 436 public override IDeepCloneable Clone(Cloner cloner) {437 ProgrammableOperator clone = (ProgrammableOperator)base.Clone(cloner);438 clone.code = Code;439 clone.executeMethod = executeMethod;440 clone.Assemblies = Assemblies.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);441 clone.namespaces = namespaces;442 clone.CompilationUnitCode = CompilationUnitCode;443 clone.CompileErrors = CompileErrors;444 clone.RegisterEvents();445 return clone;446 }447 448 #endregion449 450 452 } 451 453 } -
branches/CloningRefactoring/HeuristicLab.Operators.Views.GraphVisualization/3.3/BidirectionalLookup.cs
r4068 r4673 31 31 [Storable] 32 32 private Dictionary<TSecond, TFirst> secondToFirst; 33 34 [StorableConstructor] 35 protected BidirectionalLookup(bool deserializing) : base() { } 33 36 34 37 public BidirectionalLookup() { -
branches/CloningRefactoring/HeuristicLab.Operators.Views.GraphVisualization/3.3/General/ConnectionInfo.cs
r4068 r4673 28 28 [StorableClass] 29 29 public class ConnectionInfo : DeepCloneable, IConnectionInfo { 30 private ConnectionInfo() { 30 [StorableConstructor] 31 private ConnectionInfo(bool deserializing) : base() { } 32 private ConnectionInfo(ConnectionInfo original, Cloner cloner) 33 : base(original, cloner) { 34 from = cloner.Clone(original.from); 35 connectorFrom = original.ConnectorFrom; 36 to = cloner.Clone(original.To); 37 connectorTo = original.ConnectorTo; 38 } 39 public override IDeepCloneable Clone(Cloner cloner) { 40 return new ConnectionInfo(this, cloner); 31 41 } 32 42 public ConnectionInfo(IShapeInfo from, string connectorFrom, IShapeInfo to, string connectorTo) 33 : this() {43 : base() { 34 44 if (from == to) 35 45 throw new ArgumentException("Could not create connections between the same shape info."); … … 70 80 protected virtual void OnChanged() { 71 81 EventHandler handler = this.Changed; 72 if (handler != null) 73 this.Changed(this, EventArgs.Empty); 74 } 75 76 public override IDeepCloneable Clone(Cloner cloner) { 77 ConnectionInfo clone = (ConnectionInfo)base.Clone(cloner); 78 clone.from = (IShapeInfo)cloner.Clone(this.from); 79 clone.connectorFrom = this.ConnectorFrom; 80 clone.to = (IShapeInfo)cloner.Clone(this.To); 81 clone.connectorTo = this.ConnectorTo; 82 return clone; 82 if (handler != null) this.Changed(this, EventArgs.Empty); 83 83 } 84 84 } -
branches/CloningRefactoring/HeuristicLab.Operators.Views.GraphVisualization/3.3/General/GraphVisualizationInfo.cs
r4068 r4673 30 30 [StorableClass] 31 31 public class GraphVisualizationInfo : DeepCloneable, IGraphVisualizationInfo { 32 public GraphVisualizationInfo() { 32 [StorableConstructor] 33 protected GraphVisualizationInfo(bool deserializing) : base() { } 34 protected GraphVisualizationInfo(GraphVisualizationInfo original, Cloner cloner) 35 : base(original, cloner) { 36 shapeInfos = new ObservableSet<IShapeInfo>(original.shapeInfos.Select(x => cloner.Clone(x))); 37 connectionInfos = new ObservableSet<IConnectionInfo>(original.connectionInfos.Select(x => cloner.Clone(x))); 38 initialShape = cloner.Clone(original.initialShape); 39 } 40 public override IDeepCloneable Clone(Cloner cloner) { 41 return new GraphVisualizationInfo(this, cloner); 42 } 43 public GraphVisualizationInfo() 44 : base() { 33 45 this.shapeInfos = new ObservableSet<IShapeInfo>(); 34 46 this.connectionInfos = new ObservableSet<IConnectionInfo>(); … … 96 108 } 97 109 #endregion 98 99 public override IDeepCloneable Clone(Cloner cloner) {100 GraphVisualizationInfo clone = (GraphVisualizationInfo)base.Clone(cloner);101 clone.shapeInfos = new ObservableSet<IShapeInfo>(this.shapeInfos.Select(x => (IShapeInfo)cloner.Clone(x)));102 clone.connectionInfos = new ObservableSet<IConnectionInfo>(this.connectionInfos.Select(x => (IConnectionInfo)cloner.Clone(x)));103 if (this.initialShape != null)104 clone.initialShape = (IShapeInfo)this.initialShape.Clone(cloner);105 return clone;106 }107 110 } 108 111 } -
branches/CloningRefactoring/HeuristicLab.Operators.Views.GraphVisualization/3.3/General/ShapeInfo.cs
r4068 r4673 30 30 [StorableClass] 31 31 public abstract class ShapeInfo : DeepCloneable, IShapeInfo { 32 private ShapeInfo() { 32 [StorableConstructor] 33 protected ShapeInfo(bool deserializing) : base() { } 34 protected ShapeInfo(ShapeInfo original, Cloner cloner) 35 : base(original, cloner) { 36 shapeType = original.shapeType; 37 location = original.location; 33 38 } 34 39 … … 62 67 protected virtual void OnChanged() { 63 68 EventHandler handler = this.Changed; 64 if (handler != null) 65 this.Changed(this, EventArgs.Empty); 69 if (handler != null) this.Changed(this, EventArgs.Empty); 66 70 } 67 71 … … 80 84 this.Location = shape.Location; 81 85 } 82 83 public override IDeepCloneable Clone(Cloner cloner) {84 ShapeInfo clone = (ShapeInfo)base.Clone(cloner);85 clone.shapeType = this.shapeType;86 clone.location = this.location;87 return clone;88 }89 86 } 90 87 } -
branches/CloningRefactoring/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/OperatorGraphVisualizationInfo.cs
r4068 r4673 46 46 [StorableConstructor] 47 47 private OperatorGraphVisualizationInfo(bool deserializing) 48 : base( ) {48 : base(deserializing) { 49 49 this.operatorParameterCollectionMapping = new BidirectionalLookup<IOperator, IKeyedItemCollection<string, IParameter>>(); 50 50 this.parameterOperatorMapping = new Dictionary<IParameter, IOperator>(); 51 } 52 private OperatorGraphVisualizationInfo(OperatorGraphVisualizationInfo original, Cloner cloner) 53 : base(original, cloner) { 54 operatorShapeInfoMapping = new BidirectionalLookup<IOperator, IOperatorShapeInfo>(); 55 operatorParameterCollectionMapping = new BidirectionalLookup<IOperator, IKeyedItemCollection<string, IParameter>>(); 56 parameterOperatorMapping = new Dictionary<IParameter, IOperator>(); 57 58 operatorGraph = cloner.Clone(original.operatorGraph); 59 RegisterOperatorGraphEvents(); 60 oldInitialShape = cloner.Clone(original.oldInitialShape); 61 oldInitialShapeColor = original.oldInitialShapeColor; 62 63 foreach (KeyValuePair<IOperator, IOperatorShapeInfo> pair in original.operatorShapeInfoMapping.FirstEnumerable) { 64 IOperator op = cloner.Clone(pair.Key); 65 IOperatorShapeInfo shapeInfo = cloner.Clone(pair.Value); 66 RegisterOperatorEvents(op); 67 operatorParameterCollectionMapping.Add(op, pair.Key.Parameters); 68 operatorShapeInfoMapping.Add(op, shapeInfo); 69 } 70 71 foreach (IOperator oper in operatorShapeInfoMapping.FirstValues) { 72 foreach (IParameter param in oper.Parameters) { 73 parameterOperatorMapping.Add(param, oper); 74 IValueParameter opParam = param as IValueParameter; 75 if (opParam != null && typeof(IOperator).IsAssignableFrom(param.DataType)) 76 RegisterOperatorParameterEvents(opParam); 77 else 78 RegisterParameterEvents(param); 79 } 80 } 81 if (original.operatorGraph.InitialOperator != null) { 82 IOperatorShapeInfo newInitialShapeInfo = original.operatorShapeInfoMapping.GetByFirst(original.operatorGraph.InitialOperator); 83 if (newInitialShapeInfo != null) { 84 oldInitialShapeColor = newInitialShapeInfo.Color; 85 newInitialShapeInfo.Color = Color.LightGreen; 86 } 87 oldInitialShape = InitialShape; 88 OnInitialShapeChanged(); 89 } 90 } 91 public override IDeepCloneable Clone(Cloner cloner) { 92 return new OperatorGraphVisualizationInfo(this, cloner); 51 93 } 52 94 … … 64 106 65 107 [StorableHook(HookType.AfterDeserialization)] 66 private void DeserializationHook() {108 private void AfterDeserialization() { 67 109 this.operatorGraph.DeserializationFinished += new EventHandler(operatorGraph_DeserializationFinished); 68 110 … … 101 143 } 102 144 this.operatorGraph.DeserializationFinished -= new EventHandler(operatorGraph_DeserializationFinished); 103 }104 105 public override IDeepCloneable Clone(Cloner cloner) {106 OperatorGraphVisualizationInfo clone = (OperatorGraphVisualizationInfo)base.Clone(cloner);107 clone.operatorGraph = (OperatorGraph)cloner.Clone(this.operatorGraph);108 clone.RegisterOperatorGraphEvents();109 clone.oldInitialShape = (IOperatorShapeInfo)cloner.Clone(this.oldInitialShape);110 clone.oldInitialShapeColor = this.oldInitialShapeColor;111 112 IOperator op;113 IOperatorShapeInfo shapeInfo;114 foreach (KeyValuePair<IOperator, IOperatorShapeInfo> pair in this.operatorShapeInfoMapping.FirstEnumerable) {115 op = (IOperator)cloner.Clone(pair.Key);116 shapeInfo = (IOperatorShapeInfo)cloner.Clone(pair.Value);117 clone.RegisterOperatorEvents(op);118 clone.operatorParameterCollectionMapping.Add(op, pair.Key.Parameters);119 clone.operatorShapeInfoMapping.Add(op, shapeInfo);120 }121 122 foreach (IOperator oper in clone.operatorShapeInfoMapping.FirstValues) {123 foreach (IParameter param in oper.Parameters) {124 clone.parameterOperatorMapping.Add(param, oper);125 IValueParameter opParam = param as IValueParameter;126 if (opParam != null && typeof(IOperator).IsAssignableFrom(param.DataType))127 clone.RegisterOperatorParameterEvents(opParam);128 else129 clone.RegisterParameterEvents(param);130 }131 }132 if (this.operatorGraph.InitialOperator != null) {133 IOperatorShapeInfo newInitialShapeInfo = this.operatorShapeInfoMapping.GetByFirst(this.operatorGraph.InitialOperator);134 if (newInitialShapeInfo != null) {135 oldInitialShapeColor = newInitialShapeInfo.Color;136 newInitialShapeInfo.Color = Color.LightGreen;137 }138 oldInitialShape = this.InitialShape;139 this.OnInitialShapeChanged();140 }141 return clone;142 145 } 143 146 -
branches/CloningRefactoring/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/OperatorShapeInfo.cs
r4068 r4673 32 32 [Storable] 33 33 private List<string> labels; 34 35 [StorableConstructor] 36 protected OperatorShapeInfo(bool deserializing) : base(deserializing) { } 37 protected OperatorShapeInfo(OperatorShapeInfo original, Cloner cloner) 38 : base(original, cloner) { 39 collapsed = original.collapsed; 40 color = original.color; 41 lineColor = original.lineColor; 42 lineWidth = original.lineWidth; 43 title = original.title; 44 icon = (Bitmap)original.icon.Clone(); 45 46 connectorNames = new List<string>(original.connectorNames); 47 labels = new List<string>(original.labels); 48 } 49 public override IDeepCloneable Clone(Cloner cloner) { 50 return new OperatorShapeInfo(this, cloner); 51 } 34 52 35 53 public OperatorShapeInfo() … … 216 234 //TODO update Connector and labels; 217 235 } 218 219 public override IDeepCloneable Clone(Cloner cloner) {220 OperatorShapeInfo clone = (OperatorShapeInfo)base.Clone(cloner);221 clone.collapsed = this.collapsed;222 clone.color = this.color;223 clone.lineColor = this.lineColor;224 clone.lineWidth = this.lineWidth;225 clone.title = this.title;226 clone.icon = (Bitmap)this.icon.Clone();227 228 clone.connectorNames = new List<string>(this.connectorNames);229 clone.labels = new List<string>(this.labels);230 231 return clone;232 }233 236 } 234 237 } -
branches/CloningRefactoring/HeuristicLab.Optimization/3.3/UserDefinedAlgorithm.cs
r4670 r4673 55 55 [StorableConstructor] 56 56 private UserDefinedAlgorithm(bool deserializing) : base(deserializing) { } 57 internalUserDefinedAlgorithm(UserDefinedAlgorithm original, Cloner cloner)57 private UserDefinedAlgorithm(UserDefinedAlgorithm original, Cloner cloner) 58 58 : base(original, cloner) { 59 59 } 60 privateUserDefinedAlgorithm(EngineAlgorithm original, Cloner cloner)60 internal UserDefinedAlgorithm(EngineAlgorithm original, Cloner cloner) 61 61 : base(original, cloner) { 62 62 }
Note: See TracChangeset
for help on using the changeset viewer.