Ticket #2239: VariableStoreView.cs.patch
File VariableStoreView.cs.patch, 2.0 KB (added by bburlacu, 10 years ago) |
---|
-
3.3/VariableStoreView.cs
41 41 public partial class VariableStoreView : AsynchronousContentView { 42 42 protected Dictionary<string, ListViewItem> itemListViewItemMapping; 43 43 protected TypeSelectorDialog typeSelectorDialog; 44 private readonly Dictionary<Type, bool> serializableTypes; 44 45 protected bool validDragOperation; 45 46 46 47 public new VariableStore Content { … … 55 56 public VariableStoreView() { 56 57 InitializeComponent(); 57 58 itemListViewItemMapping = new Dictionary<string, ListViewItem>(); 59 serializableTypes = new Dictionary<Type, bool>(); 58 60 variableListView.SmallImageList.Images.AddRange(new Image[] { 59 61 HeuristicLab.Common.Resources.VSImageLibrary.Error, 60 62 HeuristicLab.Common.Resources.VSImageLibrary.Object, … … 127 129 if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) { 128 130 try { 129 131 return (object)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType(); 130 } catch (Exception ex) { 132 } 133 catch (Exception ex) { 131 134 ErrorHandling.ShowErrorDialog(this, ex); 132 135 } 133 136 } … … 411 414 } 412 415 413 416 private bool IsSerializable(KeyValuePair<string, object> variable) { 417 var type = variable.Value.GetType(); 418 if (serializableTypes.ContainsKey(type)) 419 return serializableTypes[type]; 420 414 421 var ser = new Serializer(variable, ConfigurationService.Instance.GetDefaultConfig(new XmlFormat()), "ROOT", true); 415 422 try { 416 return ser.Count() > 0; 417 } catch (PersistenceException) { 423 bool serializable = ser.Count() > 0; 424 serializableTypes[type] = serializable; 425 return serializable; 426 } 427 catch (PersistenceException) { 428 serializableTypes[type] = false; 418 429 return false; 419 430 } 420 431 }