Changeset 16953
- Timestamp:
- 05/15/19 12:17:12 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Grammars/SymbolicExpressionGrammarBase.cs
r16662 r16953 38 38 39 39 #region properties for separation between implementation and persistence 40 private List<Action> afterDeserializationActions = new List<Action>(); 40 41 [Storable(Name = "Symbols")] 41 42 private IEnumerable<ISymbol> StorableSymbols { 42 43 get { return symbols.Values.ToArray(); } 43 set { foreach (var s in value) symbols.Add(s.Name, s); }44 set { afterDeserializationActions.Add(() => { foreach (var s in value) symbols.Add(s.Name, s); }); } 44 45 } 45 46 … … 47 48 private IEnumerable<KeyValuePair<ISymbol, Tuple<int, int>>> StorableSymbolSubtreeCount { 48 49 get { return symbolSubtreeCount.Select(x => new KeyValuePair<ISymbol, Tuple<int, int>>(GetSymbol(x.Key), x.Value)).ToArray(); } 49 set { foreach (var pair in value) symbolSubtreeCount.Add(pair.Key.Name, pair.Value); }50 set { afterDeserializationActions.Add(() => { foreach (var pair in value) symbolSubtreeCount.Add(pair.Key.Name, pair.Value); }); } 50 51 } 51 52 … … 53 54 private IEnumerable<KeyValuePair<ISymbol, IEnumerable<ISymbol>>> StorableAllowedChildSymbols { 54 55 get { return allowedChildSymbols.Select(x => new KeyValuePair<ISymbol, IEnumerable<ISymbol>>(GetSymbol(x.Key), x.Value.Select(GetSymbol).ToArray())).ToArray(); } 55 set { foreach (var pair in value) allowedChildSymbols.Add(pair.Key.Name, pair.Value.Select(y => y.Name).ToList()); }56 set { afterDeserializationActions.Add(() => { foreach (var pair in value) allowedChildSymbols.Add(pair.Key.Name, pair.Value.Select(y => y.Name).ToList()); }); } 56 57 } 57 58 … … 60 61 get { return allowedChildSymbolsPerIndex.Select(x => new KeyValuePair<Tuple<ISymbol, int>, IEnumerable<ISymbol>>(Tuple.Create(GetSymbol(x.Key.Item1), x.Key.Item2), x.Value.Select(GetSymbol).ToArray())).ToArray(); } 61 62 set { 62 foreach (var pair in value) 63 allowedChildSymbolsPerIndex.Add(Tuple.Create(pair.Key.Item1.Name, pair.Key.Item2), pair.Value.Select(y => y.Name).ToList()); 63 afterDeserializationActions.Add(() => { 64 foreach (var pair in value) 65 allowedChildSymbolsPerIndex.Add(Tuple.Create(pair.Key.Item1.Name, pair.Key.Item2), pair.Value.Select(y => y.Name).ToList()); 66 }); 64 67 } 65 68 } … … 116 119 suppressEvents = false; 117 120 } 121 122 [StorableHook(HookType.AfterDeserialization)] 123 private void AfterDeserialization() { 124 foreach(var a in afterDeserializationActions) { 125 a(); 126 } 127 } 128 118 129 119 130 #region protected grammar manipulation methods
Note: See TracChangeset
for help on using the changeset viewer.