Changeset 16723 for branches/2521_ProblemRefactoring/HeuristicLab.Scripting.Views/3.3/VariableStoreView.cs
- Timestamp:
- 03/28/19 16:54:20 (6 years ago)
- Location:
- branches/2521_ProblemRefactoring
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Scripting.Views/3.3/VariableStoreView.cs
r16692 r16723 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 8Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2019 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 32 32 using HeuristicLab.MainForm.WindowsForms; 33 33 using HeuristicLab.Persistence.Core; 34 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;34 using HEAL.Attic; 35 35 using HeuristicLab.Persistence.Default.Xml; 36 36 using HeuristicLab.PluginInfrastructure; 37 using System.IO; 37 38 38 39 namespace HeuristicLab.Scripting.Views { … … 90 91 Content.ItemsRemoved -= Content_ItemsRemoved; 91 92 Content.CollectionReset -= Content_CollectionReset; 93 94 foreach (var variable in Content) { 95 var item = variable.Value as IItem; 96 if (item != null) item.ToStringChanged -= item_ToStringChanged; 97 } 98 92 99 base.DeregisterContentEvents(); 93 100 } 94 101 protected override void RegisterContentEvents() { 95 102 base.RegisterContentEvents(); 103 96 104 Content.ItemsAdded += Content_ItemsAdded; 97 105 Content.ItemsReplaced += Content_ItemsReplaced; 98 106 Content.ItemsRemoved += Content_ItemsRemoved; 99 107 Content.CollectionReset += Content_CollectionReset; 108 109 foreach (var variable in Content) { 110 var item = variable.Value as IItem; 111 if (item != null) item.ToStringChanged += item_ToStringChanged; 112 } 100 113 } 101 114 … … 474 487 private bool IsSerializable(KeyValuePair<string, object> variable) { 475 488 Type type = null; 476 bool serializable ;489 bool serializable = false; 477 490 478 491 if (variable.Value != null) { 479 492 type = variable.Value.GetType(); 480 493 if (serializableLookup.TryGetValue(type, out serializable)) return serializable; 481 if (Storable ClassAttribute.IsStorableClass(type)) return serializableLookup[type] = true;482 } 483 484 var ser = new Serializer(variable, ConfigurationService.Instance.GetDefaultConfig(new XmlFormat()), "ROOT", true);494 if (StorableTypeAttribute.IsStorableType(type)) return serializableLookup[type] = true; 495 } 496 497 var ser = new ProtoBufSerializer(); 485 498 try { 486 serializable = ser.Count() > 0; // try to create all serialization tokens 499 using (var memStream = new MemoryStream()) { 500 ser.Serialize(variable.Value, memStream); // try to serialize to memory stream 501 serializable = true; 502 } 487 503 } catch (PersistenceException) { 488 504 serializable = false;
Note: See TracChangeset
for help on using the changeset viewer.