Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/10/10 16:37:52 (15 years ago)
Author:
epitzer
Message:

add justifications for rejecting a type for serialization in ICompositeSerializer (#548)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/StorableSerializer.cs

    r2991 r2993  
    1717
    1818    public bool CanSerialize(Type type) {
    19       if (!ReflectionTools.HasDefaultConstructor(type))
     19      if (!ReflectionTools.HasDefaultConstructor(type) &&
     20        StorableConstructorAttribute.GetStorableConstructor(type) == null)
    2021        return false;
    2122      while (type != null) {
     
    2627      }
    2728      return true;
     29    }
     30
     31    public string JustifyRejection(Type type) {
     32      if (!ReflectionTools.HasDefaultConstructor(type) &&
     33        StorableConstructorAttribute.GetStorableConstructor(type) == null)
     34        return "no default constructor and no storable constructor";
     35      while (type != null) {
     36        if (StorableAttribute.GetStorableMembers(type, false).Count() == 0 &&
     37            !EmptyStorableClassAttribute.IsEmptyStorable(type))
     38          return string.Format("{0} has no storable members and is not marked [EmtpyStorableClass]",
     39            type);
     40        type = type.BaseType;
     41      }
     42      return "no reason";
    2843    }
    2944
Note: See TracChangeset for help on using the changeset viewer.