Changeset 16462 for branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers
- Timestamp:
- 12/28/18 16:10:48 (6 years ago)
- Location:
- branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers
- Files:
-
- 5 deleted
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/ArraySerializer.cs
r16453 r16462 23 23 using System.Collections.Generic; 24 24 using HeuristicLab.Persistence.Core; 25 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;25 using HEAL.Fossil; 26 26 using HeuristicLab.Persistence.Interfaces; 27 27 … … 32 32 33 33 [StorableConstructor] 34 private ArraySerializer( bool deserializing) { }34 private ArraySerializer(StorableConstructorFlag _) { } 35 35 public ArraySerializer() { } 36 36 -
branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/CompactNumberArray2StringSerializer.cs
r16453 r16462 26 26 using HeuristicLab.Persistence.Auxiliary; 27 27 using HeuristicLab.Persistence.Core; 28 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;28 using HEAL.Fossil; 29 29 using HeuristicLab.Persistence.Interfaces; 30 30 … … 82 82 83 83 [StorableConstructor] 84 private CompactNumberArray2StringSerializer( bool deserializing) { }84 private CompactNumberArray2StringSerializer(StorableConstructorFlag _) { } 85 85 public CompactNumberArray2StringSerializer() { } 86 86 -
branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/ConcreteDictionarySerializer.cs
r16453 r16462 25 25 using System.Linq; 26 26 using HeuristicLab.Persistence.Core; 27 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;27 using HEAL.Fossil; 28 28 using HeuristicLab.Persistence.Interfaces; 29 29 … … 34 34 35 35 [StorableConstructor] 36 private ConcreteDictionarySerializer( bool deserializing) { }36 private ConcreteDictionarySerializer(StorableConstructorFlag _) { } 37 37 public ConcreteDictionarySerializer() { } 38 38 -
branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/DictionarySerializer.cs
r16453 r16462 25 25 using HeuristicLab.Persistence.Auxiliary; 26 26 using HeuristicLab.Persistence.Core; 27 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;27 using HEAL.Fossil; 28 28 using HeuristicLab.Persistence.Interfaces; 29 29 … … 34 34 35 35 [StorableConstructor] 36 private DictionarySerializer( bool deserializing) { }36 private DictionarySerializer(StorableConstructorFlag _) { } 37 37 public DictionarySerializer() { } 38 38 -
branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/EnumSerializer.cs
r16453 r16462 23 23 using System.Collections.Generic; 24 24 using HeuristicLab.Persistence.Core; 25 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;25 using HEAL.Fossil; 26 26 using HeuristicLab.Persistence.Interfaces; 27 27 … … 32 32 33 33 [StorableConstructor] 34 private EnumSerializer( bool deserializing) { }34 private EnumSerializer(StorableConstructorFlag _) { } 35 35 public EnumSerializer() { } 36 36 -
branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/EnumerableSerializer.cs
r16453 r16462 26 26 using HeuristicLab.Persistence.Auxiliary; 27 27 using HeuristicLab.Persistence.Core; 28 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;28 using HEAL.Fossil; 29 29 using HeuristicLab.Persistence.Interfaces; 30 30 … … 35 35 36 36 [StorableConstructor] 37 private EnumerableSerializer( bool deserializing) { }37 private EnumerableSerializer(StorableConstructorFlag _) { } 38 38 public EnumerableSerializer() { } 39 39 -
branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/HashSetSerializer.cs
r16453 r16462 26 26 using System.Reflection; 27 27 using HeuristicLab.Persistence.Core; 28 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;28 using HEAL.Fossil; 29 29 using HeuristicLab.Persistence.Interfaces; 30 30 … … 35 35 36 36 [StorableConstructor] 37 private HashSetSerializer( bool deserializing) { }37 private HashSetSerializer(StorableConstructorFlag _) { } 38 38 public HashSetSerializer() { } 39 39 -
branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/KeyValuePairSerializer.cs
r16453 r16462 25 25 using System.Reflection; 26 26 using HeuristicLab.Persistence.Core; 27 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;27 using HEAL.Fossil; 28 28 using HeuristicLab.Persistence.Interfaces; 29 29 … … 34 34 35 35 [StorableConstructor] 36 private KeyValuePairSerializer( bool deserializing) { }36 private KeyValuePairSerializer(StorableConstructorFlag _) { } 37 37 public KeyValuePairSerializer() { } 38 38 -
branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Number2StringSerializer.cs
r16453 r16462 25 25 using HeuristicLab.Persistence.Auxiliary; 26 26 using HeuristicLab.Persistence.Core; 27 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;27 using HEAL.Fossil; 28 28 using HeuristicLab.Persistence.Default.Xml; 29 29 using HeuristicLab.Persistence.Default.Xml.Primitive; … … 44 44 45 45 [StorableConstructor] 46 private Number2StringSerializer( bool deserializing) { }46 private Number2StringSerializer(StorableConstructorFlag _) { } 47 47 public Number2StringSerializer() { } 48 48 -
branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/NumberEnumerable2StringSerializer.cs
r16453 r16462 26 26 using HeuristicLab.Persistence.Auxiliary; 27 27 using HeuristicLab.Persistence.Core; 28 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;28 using HEAL.Fossil; 29 29 using HeuristicLab.Persistence.Interfaces; 30 30 … … 35 35 36 36 [StorableConstructor] 37 private NumberEnumerable2StringSerializer( bool deserializing) { }37 private NumberEnumerable2StringSerializer(StorableConstructorFlag _) { } 38 38 public NumberEnumerable2StringSerializer() { } 39 39 -
branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/QueueSerializer.cs
r16453 r16462 25 25 using System.Reflection; 26 26 using HeuristicLab.Persistence.Core; 27 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;27 using HEAL.Fossil; 28 28 using HeuristicLab.Persistence.Interfaces; 29 29 … … 34 34 35 35 [StorableConstructor] 36 private QueueSerializer( bool deserializing) { }36 private QueueSerializer(StorableConstructorFlag _) { } 37 37 public QueueSerializer() { } 38 38 -
branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/StackSerializer.cs
r16453 r16462 25 25 using System.Reflection; 26 26 using HeuristicLab.Persistence.Core; 27 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;27 using HEAL.Fossil; 28 28 using HeuristicLab.Persistence.Interfaces; 29 29 … … 34 34 35 35 [StorableConstructor] 36 private StackSerializer( bool deserializing) { }36 private StackSerializer(StorableConstructorFlag _) { } 37 37 public StackSerializer() { } 38 38 -
branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/StorableMemberInfo.cs
r16453 r16462 23 23 using System.Reflection; 24 24 using System.Text; 25 using H euristicLab.Persistence.Core;25 using HEAL.Fossil; 26 26 27 27 namespace HeuristicLab.Persistence.Default.CompositeSerializers.Storable { -
branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/StorableReflection.cs
r16453 r16462 24 24 using System.Linq; 25 25 using System.Reflection; 26 using H euristicLab.Persistence.Core;26 using HEAL.Fossil; 27 27 28 28 namespace HeuristicLab.Persistence.Default.CompositeSerializers.Storable { … … 43 43 storableMembers.AddRange(GenerateStorableMembers(type.BaseType)); 44 44 45 var storable ClassAttribute = GetStorableClassAttribute(type);46 if (storable ClassAttribute != null) {47 switch (storable ClassAttribute.Type) {48 case Storable ClassType.MarkedOnly:45 var storableTypeAttribute = GetStorableTypeAttribute(type); 46 if (storableTypeAttribute != null) { 47 switch (storableTypeAttribute.MemberSelection) { 48 case StorableMemberSelection.MarkedOnly: 49 49 AddMarkedMembers(type, storableMembers); break; 50 case Storable ClassType.AllFields:50 case StorableMemberSelection.AllFields: 51 51 AddAll(type, MemberTypes.Field, storableMembers); break; 52 case Storable ClassType.AllProperties:52 case StorableMemberSelection.AllProperties: 53 53 AddAll(type, MemberTypes.Property, storableMembers); break; 54 case Storable ClassType.AllFieldsAndAllProperties:54 case StorableMemberSelection.AllFieldsAndAllProperties: 55 55 AddAll(type, MemberTypes.Field | MemberTypes.Property, storableMembers); break; 56 56 default: 57 throw new PersistenceException("unsupported [Storable ClassType]: " + storableClassAttribute.Type);57 throw new PersistenceException("unsupported [StorableMemberSelection]: " + storableTypeAttribute.MemberSelection); 58 58 } 59 59 } … … 62 62 63 63 public static bool IsEmptyOrStorableType(Type type, bool recursive) { 64 if (!HasStorable ClassAttribute(type) && !IsEmptyType(type, false)) return false;64 if (!HasStorableTypeAttribute(type) && !IsEmptyType(type, false)) return false; 65 65 return !recursive || type.BaseType == null || IsEmptyOrStorableType(type.BaseType, true); 66 66 } … … 72 72 foreach (var hook in CollectHooks(hookType, type.BaseType)) 73 73 yield return hook; 74 if (HasStorable ClassAttribute(type)) {74 if (HasStorableTypeAttribute(type)) { 75 75 foreach (MethodInfo methodInfo in type.GetMethods(DECLARED_INSTANCE_MEMBERS)) { 76 76 if (methodInfo.ReturnType == typeof(void) && methodInfo.GetParameters().Length == 0) { … … 174 174 #region [StorableClass] helpers 175 175 176 private static Storable ClassAttribute GetStorableClassAttribute(Type type) {177 lock (storable ClassCache) {178 if (storable ClassCache.ContainsKey(type))179 return storable ClassCache[type];180 Storable ClassAttribute attribute = type181 .GetCustomAttributes(typeof(Storable ClassAttribute), false)182 .SingleOrDefault() as Storable ClassAttribute;183 storable ClassCache.Add(type, attribute);176 private static StorableTypeAttribute GetStorableTypeAttribute(Type type) { 177 lock (storableTypeCache) { 178 if (storableTypeCache.ContainsKey(type)) 179 return storableTypeCache[type]; 180 StorableTypeAttribute attribute = type 181 .GetCustomAttributes(typeof(StorableTypeAttribute), false) 182 .SingleOrDefault() as StorableTypeAttribute; 183 storableTypeCache.Add(type, attribute); 184 184 return attribute; 185 185 } 186 186 } 187 187 188 public static bool HasStorable ClassAttribute(Type type) {189 return GetStorable ClassAttribute(type) != null;190 } 191 192 private static Dictionary<Type, Storable ClassAttribute> storableClassCache =193 new Dictionary<Type, Storable ClassAttribute>();188 public static bool HasStorableTypeAttribute(Type type) { 189 return GetStorableTypeAttribute(type) != null; 190 } 191 192 private static Dictionary<Type, StorableTypeAttribute> storableTypeCache = 193 new Dictionary<Type, StorableTypeAttribute>(); 194 194 195 195 #endregion -
branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/StorableSerializer.cs
r16453 r16462 26 26 using System.Reflection.Emit; 27 27 using System.Text; 28 using HEAL.Fossil; 28 29 using HeuristicLab.Persistence.Core; 29 30 using HeuristicLab.Persistence.Interfaces; … … 49 50 50 51 [StorableConstructor] 51 private StorableSerializer( bool deserializing) : this() { }52 private StorableSerializer(StorableConstructorFlag _) { } 52 53 53 54 #region ICompositeSerializer implementation … … 69 70 /// </returns> 70 71 public bool CanSerialize(Type type) { 71 var markedStorable = StorableReflection.HasStorable ClassAttribute(type);72 var markedStorable = StorableReflection.HasStorableTypeAttribute(type); 72 73 if (GetConstructor(type) == null) 73 74 if (markedStorable) … … 240 241 .Where(ci => ci.GetCustomAttributes(typeof(StorableConstructorAttribute), false).Length > 0)) { 241 242 if (ci.GetParameters().Length != 1 || 242 ci.GetParameters()[0].ParameterType != typeof( bool))243 throw new PersistenceException("StorableConstructor must have exactly one argument of type bool");243 ci.GetParameters()[0].ParameterType != typeof(StorableConstructorFlag)) 244 throw new PersistenceException("StorableConstructor must have exactly one argument of type StorableConstructorFlag"); 244 245 var dm = new DynamicMethod("", typeof(object), null, type, true); 245 246 var ilgen = dm.GetILGenerator(); 246 ilgen.Emit(OpCodes.Ldc_I4_1); // load true 247 var defaultFlagFieldInfo = typeof(StorableConstructorFlag).GetField("Default", BindingFlags.Static | BindingFlags.Public); 248 ilgen.Emit(OpCodes.Ldsfld, defaultFlagFieldInfo); // load the object 247 249 ilgen.Emit(OpCodes.Newobj, ci); 248 250 ilgen.Emit(OpCodes.Ret); -
branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/StructSerializer.cs
r16453 r16462 24 24 using System.Reflection; 25 25 using HeuristicLab.Persistence.Core; 26 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;26 using HEAL.Fossil; 27 27 using HeuristicLab.Persistence.Interfaces; 28 28 … … 33 33 34 34 [StorableConstructor] 35 private StructSerializer( bool deserializing) { }35 private StructSerializer(StorableConstructorFlag _) { } 36 36 public StructSerializer() { } 37 37 -
branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/TupleSerializer.cs
r16453 r16462 25 25 using System.Reflection; 26 26 using HeuristicLab.Persistence.Core; 27 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;27 using HEAL.Fossil; 28 28 using HeuristicLab.Persistence.Interfaces; 29 29 … … 34 34 35 35 [StorableConstructor] 36 private TupleSerializer( bool deserializing) { }36 private TupleSerializer(StorableConstructorFlag _) { } 37 37 public TupleSerializer() { } 38 38 -
branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/TypeSerializer.cs
r16453 r16462 24 24 using HeuristicLab.Persistence.Auxiliary; 25 25 using HeuristicLab.Persistence.Core; 26 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;26 using HEAL.Fossil; 27 27 using HeuristicLab.Persistence.Interfaces; 28 28 … … 33 33 34 34 [StorableConstructor] 35 private TypeSerializer( bool deserializing) { }35 private TypeSerializer(StorableConstructorFlag _) { } 36 36 public TypeSerializer() { } 37 37
Note: See TracChangeset
for help on using the changeset viewer.