Changeset 2994 for trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/StorableSerializer.cs
- Timestamp:
- 03/10/10 18:28:50 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/StorableSerializer.cs
r2993 r2994 9 9 namespace HeuristicLab.Persistence.Default.CompositeSerializers.Storable { 10 10 11 [EmptyStorableClass] 11 /// <summary> 12 /// Intended for serialization of all custom classes. Classes should have the 13 /// <code>[StorableClass(StorableClassType.Empty)]</code> attribute set and a serialization mode set. 14 /// Optionally selected fields and properties can be marked with the 15 /// <code>[Storable]</code> attribute. 16 /// </summary> 17 [StorableClass(StorableClassType.Empty)] 12 18 public class StorableSerializer : ICompositeSerializer { 13 19 … … 20 26 StorableConstructorAttribute.GetStorableConstructor(type) == null) 21 27 return false; 22 while (type != null) { 23 if (StorableAttribute.GetStorableMembers(type, false).Count() == 0 && 24 !EmptyStorableClassAttribute.IsEmptyStorable(type)) 25 return false; 26 type = type.BaseType; 27 } 28 return true; 28 return StorableClassAttribute.IsStorableType(type, true); 29 29 } 30 30 … … 33 33 StorableConstructorAttribute.GetStorableConstructor(type) == null) 34 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"; 35 return "class or one of its base classes is not empty and has no [StorableClass(StorableClassType.Empty)] attribute"; 43 36 } 44 37 … … 59 52 try { 60 53 ConstructorInfo constructor = StorableConstructorAttribute.GetStorableConstructor(type); 61 return constructor != null ? constructor.Invoke(defaultArgs) : Activator.CreateInstance(type, true);54 return constructor != null ? constructor.Invoke(defaultArgs) : Activator.CreateInstance(type, true); 62 55 } catch (TargetInvocationException x) { 63 56 throw new PersistenceException( … … 72 65 while (iter.MoveNext()) { 73 66 memberDict.Add(iter.Current.Name, iter.Current); 74 } 67 } 75 68 foreach (var accessor in StorableAttribute.GetStorableAccessors(instance)) { 76 69 if (memberDict.ContainsKey(accessor.Name)) {
Note: See TracChangeset
for help on using the changeset viewer.