Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/17/11 14:41:30 (14 years ago)
Author:
epitzer
Message:

use static cache of storable information (#1530)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/PersistenceSpeedUp/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/StorableSerializer.cs

    r6214 r6222  
    4141  public sealed class StorableSerializer : ICompositeSerializer {
    4242
    43     private StorableClassAnalyzer analyzer;
    44 
    45     public StorableSerializer() {
    46       analyzer = new StorableClassAnalyzer();
    47     }
     43    public StorableSerializer() { }
    4844
    4945    [StorableConstructor]
     
    6864    /// </returns>
    6965    public bool CanSerialize(Type type) {
    70       TypeDescriptor desc = analyzer[type];
     66      TypeDescriptor desc = StorableClassAnalyzer.GetDescriptor(type);
    7167      if (desc.IsInvalid)
    7268        return false;
     
    9187    public string JustifyRejection(Type type) {
    9288      StringBuilder sb = new StringBuilder();
    93       TypeDescriptor desc = analyzer[type];
     89      TypeDescriptor desc = StorableClassAnalyzer.GetDescriptor(type);
    9490      if (desc.IsInvalid)
    9591        sb.Append("class is not marked [StorableClass] but has mutable members.");
     
    120116    /// <returns>An enumerable of <see cref="Tag"/>s.</returns>
    121117    public IEnumerable<Tag> Decompose(object obj) {
    122       foreach (var kvp in analyzer[obj.GetType()].Decompose(obj)) {
     118      foreach (var kvp in StorableClassAnalyzer.GetDescriptor(obj.GetType()).Decompose(obj)) {
    123119        yield return new Tag(kvp.Key, kvp.Value);
    124120      }
     
    133129    public object CreateInstance(Type type, IEnumerable<Tag> metaInfo) {
    134130      try {
    135         return analyzer[type].CreateInstance();
     131        return StorableClassAnalyzer.GetDescriptor(type).CreateInstance();
    136132      } catch (TargetInvocationException x) {
    137133        throw new PersistenceException(
     
    148144    /// <param name="type">The type.</param>
    149145    public void Populate(object instance, IEnumerable<Tag> objects, Type type) {
    150       analyzer[type].Populate(instance, objects.ToDictionary(kvp => kvp.Name, kvp => kvp.Value));
     146      StorableClassAnalyzer.GetDescriptor(type).Populate(instance, objects.ToDictionary(kvp => kvp.Name, kvp => kvp.Value));
    151147    }
    152148
Note: See TracChangeset for help on using the changeset viewer.