Changeset 6114
- Timestamp:
- 05/03/11 19:25:13 (14 years ago)
- Location:
- trunk/sources
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Common/3.3/ObjectExtensions.cs
r6103 r6114 37 37 objects.Add(obj); 38 38 39 if (obj is ValueType || obj is string) return; 39 //if (obj is ValueType || obj is string) return; 40 if (obj is Pointer) return; 40 41 41 42 IEnumerable enumerable = obj as IEnumerable; -
trunk/sources/HeuristicLab.Common/3.3/TypeExtensions.cs
r6103 r6114 47 47 return sb.ToString(); 48 48 } 49 49 50 public static IEnumerable<FieldInfo> GetAllFields(this Type type) { 50 foreach (var field in type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))51 foreach (var field in type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)) 51 52 yield return field; 52 53 53 foreach (var field in type.GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)) 54 foreach (var field in type.GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)) 54 55 yield return field; 55 56 56 57 if (type.BaseType != null) { 57 58 foreach (var field in type.BaseType.GetAllFields()) … … 59 60 } 60 61 } 62 61 63 // http://stackoverflow.com/questions/457676/c-reflection-check-if-a-class-is-derived-from-a-generic-class 62 64 public static bool IsSubclassOfRawGeneric(this Type toCheck, Type generic) { -
trunk/sources/HeuristicLab.Operators/3.3/Operator.cs
r6103 r6114 74 74 protected Operator(bool deserializing) 75 75 : base(deserializing) { 76 InitializeState();76 executionContexts = new Lazy<ThreadLocal<IExecutionContext>>(() => { return new ThreadLocal<IExecutionContext>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 77 77 } 78 78 protected Operator(Operator original, Cloner cloner) 79 79 : base(original, cloner) { 80 InitializeState();80 executionContexts = new Lazy<ThreadLocal<IExecutionContext>>(() => { return new ThreadLocal<IExecutionContext>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 81 81 this.breakpoint = original.breakpoint; 82 82 } 83 83 protected Operator() 84 84 : base() { 85 InitializeState();85 executionContexts = new Lazy<ThreadLocal<IExecutionContext>>(() => { return new ThreadLocal<IExecutionContext>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 86 86 breakpoint = false; 87 87 } 88 88 protected Operator(string name) 89 89 : base(name) { 90 InitializeState();90 executionContexts = new Lazy<ThreadLocal<IExecutionContext>>(() => { return new ThreadLocal<IExecutionContext>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 91 91 breakpoint = false; 92 92 } 93 93 protected Operator(string name, ParameterCollection parameters) 94 94 : base(name, parameters) { 95 InitializeState();95 executionContexts = new Lazy<ThreadLocal<IExecutionContext>>(() => { return new ThreadLocal<IExecutionContext>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 96 96 breakpoint = false; 97 97 } 98 98 protected Operator(string name, string description) 99 99 : base(name, description) { 100 InitializeState();100 executionContexts = new Lazy<ThreadLocal<IExecutionContext>>(() => { return new ThreadLocal<IExecutionContext>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 101 101 breakpoint = false; 102 102 } 103 103 protected Operator(string name, string description, ParameterCollection parameters) 104 104 : base(name, description, parameters) { 105 InitializeState();105 executionContexts = new Lazy<ThreadLocal<IExecutionContext>>(() => { return new ThreadLocal<IExecutionContext>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 106 106 breakpoint = false; 107 107 } 108 108 109 public virtual void InitializeState() { 109 public virtual void InitializeState() { } 110 public virtual void ClearState() { 110 111 executionContexts = new Lazy<ThreadLocal<IExecutionContext>>(() => { return new ThreadLocal<IExecutionContext>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 111 }112 public virtual void ClearState() {113 executionContexts = null;114 112 } 115 113 … … 123 121 OnExecuted(); 124 122 return next; 125 } finally { 123 } 124 finally { 126 125 foreach (IParameter param in Parameters) 127 126 param.ExecutionContext = null; -
trunk/sources/HeuristicLab.Optimization/3.3/Algorithms/Algorithm.cs
r6103 r6114 260 260 public event EventHandler Prepared; 261 261 protected virtual void OnPrepared() { 262 ExecutionState = ExecutionState.Prepared; 262 263 ExecutionTime = TimeSpan.Zero; 263 264 foreach (IStatefulItem statefulObject in this.GetObjectGraphObjects().OfType<IStatefulItem>()) { 264 265 statefulObject.InitializeState(); 265 266 } 266 ExecutionState = ExecutionState.Prepared;267 267 EventHandler handler = Prepared; 268 268 if (handler != null) handler(this, EventArgs.Empty); -
trunk/sources/HeuristicLab.Parameters/3.3/Parameter.cs
r6103 r6114 92 92 protected Parameter(bool deserializing) 93 93 : base(deserializing) { 94 InitializeState(); 94 cachedActualValues = new Lazy<ThreadLocal<IItem>>(() => { return new ThreadLocal<IItem>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 95 executionContexts = new Lazy<ThreadLocal<IExecutionContext>>(() => { return new ThreadLocal<IExecutionContext>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 95 96 } 96 97 protected Parameter(Parameter original, Cloner cloner) … … 98 99 dataType = original.dataType; 99 100 hidden = original.hidden; 100 InitializeState(); 101 cachedActualValues = new Lazy<ThreadLocal<IItem>>(() => { return new ThreadLocal<IItem>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 102 executionContexts = new Lazy<ThreadLocal<IExecutionContext>>(() => { return new ThreadLocal<IExecutionContext>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 101 103 } 102 104 protected Parameter() … … 104 106 dataType = typeof(IItem); 105 107 hidden = false; 106 InitializeState(); 108 cachedActualValues = new Lazy<ThreadLocal<IItem>>(() => { return new ThreadLocal<IItem>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 109 executionContexts = new Lazy<ThreadLocal<IExecutionContext>>(() => { return new ThreadLocal<IExecutionContext>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 107 110 } 108 111 protected Parameter(string name, Type dataType) … … 111 114 this.dataType = dataType; 112 115 hidden = false; 113 InitializeState(); 116 cachedActualValues = new Lazy<ThreadLocal<IItem>>(() => { return new ThreadLocal<IItem>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 117 executionContexts = new Lazy<ThreadLocal<IExecutionContext>>(() => { return new ThreadLocal<IExecutionContext>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 114 118 } 115 119 protected Parameter(string name, string description, Type dataType) … … 118 122 this.dataType = dataType; 119 123 hidden = false; 120 InitializeState();121 }122 123 public virtual void InitializeState() {124 124 cachedActualValues = new Lazy<ThreadLocal<IItem>>(() => { return new ThreadLocal<IItem>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 125 125 executionContexts = new Lazy<ThreadLocal<IExecutionContext>>(() => { return new ThreadLocal<IExecutionContext>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 126 126 } 127 128 public virtual void InitializeState() { } 127 129 public virtual void ClearState() { 128 cachedActualValues = n ull;129 executionContexts = n ull;130 cachedActualValues = new Lazy<ThreadLocal<IItem>>(() => { return new ThreadLocal<IItem>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 131 executionContexts = new Lazy<ThreadLocal<IExecutionContext>>(() => { return new ThreadLocal<IExecutionContext>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 130 132 } 131 133
Note: See TracChangeset
for help on using the changeset viewer.