Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11437 for trunk/sources


Ignore:
Timestamp:
10/09/14 18:12:20 (10 years ago)
Author:
jkarder
Message:

#2239: applied a slightly modified version of bburlacu's patch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Scripting.Views/3.3/VariableStoreView.cs

    r11436 r11437  
    4040  [Content(typeof(VariableStore), true)]
    4141  public partial class VariableStoreView : AsynchronousContentView {
    42     protected Dictionary<string, ListViewItem> itemListViewItemMapping;
     42    protected readonly Dictionary<string, ListViewItem> itemListViewItemMapping;
     43    protected readonly Dictionary<Type, bool> serializableLookup;
    4344    protected TypeSelectorDialog typeSelectorDialog;
    4445    protected bool validDragOperation;
     
    5657      InitializeComponent();
    5758      itemListViewItemMapping = new Dictionary<string, ListViewItem>();
     59      serializableLookup = new Dictionary<Type, bool>();
    5860      variableListView.SmallImageList.Images.AddRange(new Image[] {
    5961        HeuristicLab.Common.Resources.VSImageLibrary.Error,
     
    397399
    398400    private bool IsSerializable(KeyValuePair<string, object> variable) {
     401      var type = variable.Value.GetType();
     402      bool serializable;
     403      if (serializableLookup.TryGetValue(type, out serializable))
     404        return serializable;
    399405      var ser = new Serializer(variable, ConfigurationService.Instance.GetDefaultConfig(new XmlFormat()), "ROOT", true);
    400406      try {
    401         return ser.Count() > 0;
     407        return serializableLookup[type] = ser.Any();
    402408      } catch (PersistenceException) {
    403         return false;
     409        return serializableLookup[type] = false;
    404410      }
    405411    }
Note: See TracChangeset for help on using the changeset viewer.