Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/23/09 14:22:29 (15 years ago)
Author:
epitzer
Message:

Added PersistenceException used consistently for all error conditions in the persistence framework (#548)

File:
1 edited

Legend:

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

    r1623 r1625  
    2828
    2929    public object CreateInstance(Type type, IEnumerable<Tag> metaInfo) {
    30       foreach (var typeName in metaInfo) {
    31         return Type.GetType((string)typeName.Value);
     30      IEnumerator<Tag> it = metaInfo.GetEnumerator();
     31      try {
     32        it.MoveNext();
     33      } catch (InvalidOperationException e) {
     34        throw new PersistenceException("Insufficient meta information to instantiate Type object", e);
    3235      }
    33       return null;
     36      try {
     37        return Type.GetType((string)it.Current.Value, true);
     38      } catch (InvalidCastException e) {
     39        throw new PersistenceException("Invalid meta information during reconstruction of Type object", e);
     40      } catch (TypeLoadException e) {
     41        throw new PersistenceException(String.Format(
     42          "Cannot load Type {0}, make sure all required assemblies are available.",
     43          (string)it.Current.Value), e);
     44      }
    3445    }
    3546
    3647    public void Populate(object instance, IEnumerable<Tag> objects, Type type) {
     48      // Type ojects are populated during instance creation.
    3749    }
    3850  }
Note: See TracChangeset for help on using the changeset viewer.