Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/23/09 17:41:55 (16 years ago)
Author:
epitzer
Message:

support for default disabled decomposers, re-activate number2string decomposer with negative priority. (#548)

Location:
trunk/sources/HeuristicLab.Persistence/3.3/Default/Decomposers
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Decomposers/CompactNumberArray2StringDecomposer.cs

    r1625 r1644  
    1717    }
    1818
    19     private static readonly Number2StringConverter numberConverter =
    20       new Number2StringConverter();
     19    private static readonly Number2StringDecomposer numberConverter =
     20      new Number2StringDecomposer();
    2121
    2222    public bool CanDecompose(Type type) {
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Decomposers/Number2StringConverter.cs

    r1625 r1644  
    99namespace HeuristicLab.Persistence.Default.Decomposers {
    1010
    11   public class Number2StringConverter {
     11  public class Number2StringDecomposer : IDecomposer {
    1212
    1313    private static readonly List<Type> numberTypes =
     
    2929    private static readonly Dictionary<Type, MethodInfo> numberParsers;
    3030
    31     static Number2StringConverter() {
     31    static Number2StringDecomposer() {
    3232      numberParsers = new Dictionary<Type, MethodInfo>();
    3333      foreach (var type in numberTypes) {
     
    6565    }
    6666
     67
     68    #region IDecomposer Members
     69
     70    public int Priority {
     71      get { return -100; }
     72    }
     73
     74    public IEnumerable<Tag> CreateMetaInfo(object obj) {
     75      yield return new Tag(Format(obj));
     76    }
     77
     78    public IEnumerable<Tag> Decompose(object obj) {
     79      // numbers are composed just of meta info
     80      return new Tag[] { };
     81    }
     82
     83    public object CreateInstance(Type type, IEnumerable<Tag> metaInfo) {
     84      var it = metaInfo.GetEnumerator();
     85      try {
     86        it.MoveNext();
     87        return Parse((string)it.Current.Value, type);
     88      } catch (InvalidOperationException e) {
     89        throw new PersistenceException(
     90          String.Format("Insufficient meta information to reconstruct number of type {0}.",
     91          type.VersionInvariantName()), e);
     92      } catch (InvalidCastException e) {
     93        throw new PersistenceException("Invalid meta information element type", e);
     94      }
     95    }
     96
     97    public void Populate(object instance, IEnumerable<Tag> tags, Type type) {
     98      // numbers are composed just of meta info, no need to populate
     99    }
     100
     101    #endregion
    67102  }
    68103
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Decomposers/NumberEnumerable2StringDecomposer.cs

    r1625 r1644  
    1717    }
    1818
    19     private static readonly Number2StringConverter numberConverter =
    20       new Number2StringConverter();
     19    private static readonly Number2StringDecomposer numberConverter =
     20      new Number2StringDecomposer();
    2121
    2222    private static readonly Dictionary<Type, Type> interfaceCache = new Dictionary<Type, Type>();
Note: See TracChangeset for help on using the changeset viewer.