Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/08/09 11:03:36 (16 years ago)
Author:
epitzer
Message:

Add Priority property to IDecomposer interface to allow specialized decomposers to be tried first. (#578)

Location:
trunk/sources/HeuristicLab.Persistence/3.3
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Persistence/3.3/Core/ConfigurationService.cs

    r1473 r1539  
    8484        if ( a != defaultAssembly )
    8585          DiscoverFrom(a);
     86      SortDecomposers();
     87    }
     88
     89    class PriortiySorter : IComparer<IDecomposer> {
     90      public int Compare(IDecomposer x, IDecomposer y) {
     91        return y.Priority - x.Priority;
     92      }
     93    }
     94
     95    protected void SortDecomposers() {
     96      Decomposers.Sort(new PriortiySorter());
    8697    }
    8798
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Decomposers/ArrayDecomposer.cs

    r1518 r1539  
    77   
    88  public class ArrayDecomposer : IDecomposer {
     9
     10    public int Priority {
     11      get { return 100; }
     12    }
    913
    1014    public bool CanDecompose(Type type) {
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Decomposers/DictionaryDecomposer.cs

    r1454 r1539  
    4141  public class DictionaryDecomposer : IDecomposer {
    4242
     43    public int Priority {
     44      get { return 100; }
     45    }
     46
     47
    4348    public bool CanDecompose(Type type) {
    4449      return type.GetInterface(typeof(IDictionary).FullName) != null;       
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Decomposers/EnumDecomposer.cs

    r1456 r1539  
    77   
    88  public class EnumDecomposer : IDecomposer {
     9
     10    public int Priority {
     11      get { return 100; }
     12    }
    913
    1014    public bool CanDecompose(Type type) {
     
    2529      return Enum.Parse(t, (string)it.Current.Value);
    2630    }
     31   
    2732  }
    2833 
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Decomposers/EnumerableDecomposer.cs

    r1454 r1539  
    4949  }
    5050
    51   public class EnumerableDecomposer : IDecomposer {   
     51  public class EnumerableDecomposer : IDecomposer {
     52
     53    public int Priority {
     54      get { return 100; }
     55    }
     56
    5257
    5358    public bool CanDecompose(Type type) {
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Decomposers/KeyValuePairDecomposer.cs

    r1454 r1539  
    88namespace HeuristicLab.Persistence.Default.Decomposers {
    99 
    10   public class KeyValuePairDecomposer : IDecomposer {   
     10  public class KeyValuePairDecomposer : IDecomposer {
     11
     12    public int Priority {
     13      get { return 100; }
     14    }
     15
    1116
    1217    public bool CanDecompose(Type type) {
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Decomposers/StorableDecomposer.cs

    r1454 r1539  
    77namespace HeuristicLab.Persistence.Default.Decomposers {
    88
    9   public class StorableDecomposer : IDecomposer {   
     9  public class StorableDecomposer : IDecomposer {
     10
     11    public int Priority {
     12      get { return 200; }
     13    }
    1014
    1115    public bool CanDecompose(Type type) {
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Decomposers/TypeDecomposer.cs

    r1454 r1539  
    66namespace HeuristicLab.Persistence.Default.Decomposers {
    77 
    8   public class TypeDecomposer : IDecomposer {   
     8  public class TypeDecomposer : IDecomposer {
     9
     10    public int Priority {
     11      get { return 100; }
     12    }
     13
    914    public bool CanDecompose(Type type) {
    1015      return type == typeof (Type) ||
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Decomposers/X2StringDecomposer.cs

    r1518 r1539  
    1010
    1111  public class Number2StringDecomposer : IDecomposer {
     12
     13    public int Priority {
     14      get { return 100; }
     15    }
     16
    1217
    1318    private static readonly List<Type> numberTypes =
     
    7782  public class DateTime2StringDecomposer : IDecomposer {
    7883
     84    public int Priority {
     85      get { return 100; }
     86    }
     87
     88
    7989    public bool CanDecompose(Type type) {
    8090      return type == typeof(DateTime);
     
    99109
    100110  public class CompactNumberArray2StringDecomposer : IDecomposer {
     111
     112    public int Priority {
     113      get { return 200; }
     114    }
    101115   
    102116    private static readonly Number2StringDecomposer numberDecomposer =
     
    183197
    184198  public class NumberEnumerable2StringDecomposer : IDecomposer {
     199
     200    public int Priority {
     201      get { return 200; }
     202    }
    185203
    186204    private static readonly Number2StringDecomposer numberDecomposer =
  • trunk/sources/HeuristicLab.Persistence/3.3/Interfaces/IDecomposer.cs

    r1454 r1539  
    66
    77  public interface IDecomposer {
     8
     9    /// <summary>
     10    /// Defines the Priorty of this Decomposer. Higher number means
     11    /// higher prioriy. Negative numbers are fallback decomposers.
     12    /// All default generic decomposers have priority 100. Specializations
     13    /// have priority 200 so they will  be tried first. Priorities are
     14    /// only considered for default configurations.
     15    /// </summary>
     16    int Priority { get; }
    817
    918    /// <summary>
Note: See TracChangeset for help on using the changeset viewer.