Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/28/18 16:10:48 (6 years ago)
Author:
jkarder
Message:

#2520: worked on reintegration of new persistence

  • added nuget references to HEAL.Fossil
  • added StorableType attributes to many classes
  • changed signature of StorableConstructors
  • removed some classes in old persistence
  • removed some unnecessary usings
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  
    2323using System.Collections.Generic;
    2424using HeuristicLab.Persistence.Core;
    25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     25using HEAL.Fossil;
    2626using HeuristicLab.Persistence.Interfaces;
    2727
     
    3232
    3333    [StorableConstructor]
    34     private ArraySerializer(bool deserializing) { }
     34    private ArraySerializer(StorableConstructorFlag _) { }
    3535    public ArraySerializer() { }
    3636
  • branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/CompactNumberArray2StringSerializer.cs

    r16453 r16462  
    2626using HeuristicLab.Persistence.Auxiliary;
    2727using HeuristicLab.Persistence.Core;
    28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     28using HEAL.Fossil;
    2929using HeuristicLab.Persistence.Interfaces;
    3030
     
    8282
    8383    [StorableConstructor]
    84     private CompactNumberArray2StringSerializer(bool deserializing) { }
     84    private CompactNumberArray2StringSerializer(StorableConstructorFlag _) { }
    8585    public CompactNumberArray2StringSerializer() { }
    8686
  • branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/ConcreteDictionarySerializer.cs

    r16453 r16462  
    2525using System.Linq;
    2626using HeuristicLab.Persistence.Core;
    27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     27using HEAL.Fossil;
    2828using HeuristicLab.Persistence.Interfaces;
    2929
     
    3434
    3535    [StorableConstructor]
    36     private ConcreteDictionarySerializer(bool deserializing) { }
     36    private ConcreteDictionarySerializer(StorableConstructorFlag _) { }
    3737    public ConcreteDictionarySerializer() { }
    3838
  • branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/DictionarySerializer.cs

    r16453 r16462  
    2525using HeuristicLab.Persistence.Auxiliary;
    2626using HeuristicLab.Persistence.Core;
    27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     27using HEAL.Fossil;
    2828using HeuristicLab.Persistence.Interfaces;
    2929
     
    3434
    3535    [StorableConstructor]
    36     private DictionarySerializer(bool deserializing) { }
     36    private DictionarySerializer(StorableConstructorFlag _) { }
    3737    public DictionarySerializer() { }
    3838
  • branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/EnumSerializer.cs

    r16453 r16462  
    2323using System.Collections.Generic;
    2424using HeuristicLab.Persistence.Core;
    25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     25using HEAL.Fossil;
    2626using HeuristicLab.Persistence.Interfaces;
    2727
     
    3232
    3333    [StorableConstructor]
    34     private EnumSerializer(bool deserializing) { }
     34    private EnumSerializer(StorableConstructorFlag _) { }
    3535    public EnumSerializer() { }
    3636
  • branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/EnumerableSerializer.cs

    r16453 r16462  
    2626using HeuristicLab.Persistence.Auxiliary;
    2727using HeuristicLab.Persistence.Core;
    28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     28using HEAL.Fossil;
    2929using HeuristicLab.Persistence.Interfaces;
    3030
     
    3535
    3636    [StorableConstructor]
    37     private EnumerableSerializer(bool deserializing) { }
     37    private EnumerableSerializer(StorableConstructorFlag _) { }
    3838    public EnumerableSerializer() { }
    3939
  • branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/HashSetSerializer.cs

    r16453 r16462  
    2626using System.Reflection;
    2727using HeuristicLab.Persistence.Core;
    28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     28using HEAL.Fossil;
    2929using HeuristicLab.Persistence.Interfaces;
    3030
     
    3535
    3636    [StorableConstructor]
    37     private HashSetSerializer(bool deserializing) { }
     37    private HashSetSerializer(StorableConstructorFlag _) { }
    3838    public HashSetSerializer() { }
    3939
  • branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/KeyValuePairSerializer.cs

    r16453 r16462  
    2525using System.Reflection;
    2626using HeuristicLab.Persistence.Core;
    27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     27using HEAL.Fossil;
    2828using HeuristicLab.Persistence.Interfaces;
    2929
     
    3434
    3535    [StorableConstructor]
    36     private KeyValuePairSerializer(bool deserializing) { }
     36    private KeyValuePairSerializer(StorableConstructorFlag _) { }
    3737    public KeyValuePairSerializer() { }
    3838
  • branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Number2StringSerializer.cs

    r16453 r16462  
    2525using HeuristicLab.Persistence.Auxiliary;
    2626using HeuristicLab.Persistence.Core;
    27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     27using HEAL.Fossil;
    2828using HeuristicLab.Persistence.Default.Xml;
    2929using HeuristicLab.Persistence.Default.Xml.Primitive;
     
    4444
    4545    [StorableConstructor]
    46     private Number2StringSerializer(bool deserializing) { }
     46    private Number2StringSerializer(StorableConstructorFlag _) { }
    4747    public Number2StringSerializer() { }
    4848
  • branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/NumberEnumerable2StringSerializer.cs

    r16453 r16462  
    2626using HeuristicLab.Persistence.Auxiliary;
    2727using HeuristicLab.Persistence.Core;
    28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     28using HEAL.Fossil;
    2929using HeuristicLab.Persistence.Interfaces;
    3030
     
    3535
    3636    [StorableConstructor]
    37     private NumberEnumerable2StringSerializer(bool deserializing) { }
     37    private NumberEnumerable2StringSerializer(StorableConstructorFlag _) { }
    3838    public NumberEnumerable2StringSerializer() { }
    3939
  • branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/QueueSerializer.cs

    r16453 r16462  
    2525using System.Reflection;
    2626using HeuristicLab.Persistence.Core;
    27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     27using HEAL.Fossil;
    2828using HeuristicLab.Persistence.Interfaces;
    2929
     
    3434
    3535    [StorableConstructor]
    36     private QueueSerializer(bool deserializing) { }
     36    private QueueSerializer(StorableConstructorFlag _) { }
    3737    public QueueSerializer() { }
    3838
  • branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/StackSerializer.cs

    r16453 r16462  
    2525using System.Reflection;
    2626using HeuristicLab.Persistence.Core;
    27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     27using HEAL.Fossil;
    2828using HeuristicLab.Persistence.Interfaces;
    2929
     
    3434
    3535    [StorableConstructor]
    36     private StackSerializer(bool deserializing) { }
     36    private StackSerializer(StorableConstructorFlag _) { }
    3737    public StackSerializer() { }
    3838
  • branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/StorableMemberInfo.cs

    r16453 r16462  
    2323using System.Reflection;
    2424using System.Text;
    25 using HeuristicLab.Persistence.Core;
     25using HEAL.Fossil;
    2626
    2727namespace HeuristicLab.Persistence.Default.CompositeSerializers.Storable {
  • branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/StorableReflection.cs

    r16453 r16462  
    2424using System.Linq;
    2525using System.Reflection;
    26 using HeuristicLab.Persistence.Core;
     26using HEAL.Fossil;
    2727
    2828namespace HeuristicLab.Persistence.Default.CompositeSerializers.Storable {
     
    4343        storableMembers.AddRange(GenerateStorableMembers(type.BaseType));
    4444
    45       var storableClassAttribute = GetStorableClassAttribute(type);
    46       if (storableClassAttribute != null) {
    47         switch (storableClassAttribute.Type) {
    48           case StorableClassType.MarkedOnly:
     45      var storableTypeAttribute = GetStorableTypeAttribute(type);
     46      if (storableTypeAttribute != null) {
     47        switch (storableTypeAttribute.MemberSelection) {
     48          case StorableMemberSelection.MarkedOnly:
    4949            AddMarkedMembers(type, storableMembers); break;
    50           case StorableClassType.AllFields:
     50          case StorableMemberSelection.AllFields:
    5151            AddAll(type, MemberTypes.Field, storableMembers); break;
    52           case StorableClassType.AllProperties:
     52          case StorableMemberSelection.AllProperties:
    5353            AddAll(type, MemberTypes.Property, storableMembers); break;
    54           case StorableClassType.AllFieldsAndAllProperties:
     54          case StorableMemberSelection.AllFieldsAndAllProperties:
    5555            AddAll(type, MemberTypes.Field | MemberTypes.Property, storableMembers); break;
    5656          default:
    57             throw new PersistenceException("unsupported [StorableClassType]: " + storableClassAttribute.Type);
     57            throw new PersistenceException("unsupported [StorableMemberSelection]: " + storableTypeAttribute.MemberSelection);
    5858        }
    5959      }
     
    6262
    6363    public static bool IsEmptyOrStorableType(Type type, bool recursive) {
    64       if (!HasStorableClassAttribute(type) && !IsEmptyType(type, false)) return false;
     64      if (!HasStorableTypeAttribute(type) && !IsEmptyType(type, false)) return false;
    6565      return !recursive || type.BaseType == null || IsEmptyOrStorableType(type.BaseType, true);
    6666    }
     
    7272        foreach (var hook in CollectHooks(hookType, type.BaseType))
    7373          yield return hook;
    74       if (HasStorableClassAttribute(type)) {
     74      if (HasStorableTypeAttribute(type)) {
    7575        foreach (MethodInfo methodInfo in type.GetMethods(DECLARED_INSTANCE_MEMBERS)) {
    7676          if (methodInfo.ReturnType == typeof(void) && methodInfo.GetParameters().Length == 0) {
     
    174174    #region [StorableClass] helpers
    175175
    176     private static StorableClassAttribute GetStorableClassAttribute(Type type) {
    177       lock (storableClassCache) {
    178         if (storableClassCache.ContainsKey(type))
    179           return storableClassCache[type];
    180         StorableClassAttribute attribute = type
    181           .GetCustomAttributes(typeof(StorableClassAttribute), false)
    182           .SingleOrDefault() as StorableClassAttribute;
    183         storableClassCache.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);
    184184        return attribute;
    185185      }
    186186    }
    187187
    188     public static bool HasStorableClassAttribute(Type type) {
    189       return GetStorableClassAttribute(type) != null;
    190     }
    191 
    192     private static Dictionary<Type, StorableClassAttribute> storableClassCache =
    193       new Dictionary<Type, StorableClassAttribute>();
     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>();
    194194
    195195    #endregion
  • branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/StorableSerializer.cs

    r16453 r16462  
    2626using System.Reflection.Emit;
    2727using System.Text;
     28using HEAL.Fossil;
    2829using HeuristicLab.Persistence.Core;
    2930using HeuristicLab.Persistence.Interfaces;
     
    4950
    5051    [StorableConstructor]
    51     private StorableSerializer(bool deserializing) : this() { }
     52    private StorableSerializer(StorableConstructorFlag _) { }
    5253
    5354    #region ICompositeSerializer implementation
     
    6970    /// </returns>
    7071    public bool CanSerialize(Type type) {
    71       var markedStorable = StorableReflection.HasStorableClassAttribute(type);
     72      var markedStorable = StorableReflection.HasStorableTypeAttribute(type);
    7273      if (GetConstructor(type) == null)
    7374        if (markedStorable)
     
    240241        .Where(ci => ci.GetCustomAttributes(typeof(StorableConstructorAttribute), false).Length > 0)) {
    241242        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");
    244245        var dm = new DynamicMethod("", typeof(object), null, type, true);
    245246        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
    247249        ilgen.Emit(OpCodes.Newobj, ci);
    248250        ilgen.Emit(OpCodes.Ret);
  • branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/StructSerializer.cs

    r16453 r16462  
    2424using System.Reflection;
    2525using HeuristicLab.Persistence.Core;
    26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     26using HEAL.Fossil;
    2727using HeuristicLab.Persistence.Interfaces;
    2828
     
    3333
    3434    [StorableConstructor]
    35     private StructSerializer(bool deserializing) { }
     35    private StructSerializer(StorableConstructorFlag _) { }
    3636    public StructSerializer() { }
    3737
  • branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/TupleSerializer.cs

    r16453 r16462  
    2525using System.Reflection;
    2626using HeuristicLab.Persistence.Core;
    27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     27using HEAL.Fossil;
    2828using HeuristicLab.Persistence.Interfaces;
    2929
     
    3434
    3535    [StorableConstructor]
    36     private TupleSerializer(bool deserializing) { }
     36    private TupleSerializer(StorableConstructorFlag _) { }
    3737    public TupleSerializer() { }
    3838
  • branches/2520_PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/TypeSerializer.cs

    r16453 r16462  
    2424using HeuristicLab.Persistence.Auxiliary;
    2525using HeuristicLab.Persistence.Core;
    26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     26using HEAL.Fossil;
    2727using HeuristicLab.Persistence.Interfaces;
    2828
     
    3333
    3434    [StorableConstructor]
    35     private TypeSerializer(bool deserializing) { }
     35    private TypeSerializer(StorableConstructorFlag _) { }
    3636    public TypeSerializer() { }
    3737
Note: See TracChangeset for help on using the changeset viewer.