Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/01/17 11:29:49 (8 years ago)
Author:
gkronber
Message:

#2520 introduced StorableConstructorFlag type for StorableConstructors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/PersistenceReintegration/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/StorableSerializer.cs

    r14928 r15018  
    5050
    5151    [StorableConstructor]
    52     private StorableSerializer(bool deserializing) : this() { }
     52    private StorableSerializer(StorableConstructorFlag deserializing) : this() { }
    5353
    5454    #region ICompositeSerializer implementation
     
    241241        .Where(ci => ci.GetCustomAttributes(typeof(StorableConstructorAttribute), false).Length > 0)) {
    242242        if (ci.GetParameters().Length != 1 ||
    243             ci.GetParameters()[0].ParameterType != typeof(bool))
    244           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");
    245245        var dm = new DynamicMethod("", typeof(object), null, type, true);
    246246        var ilgen = dm.GetILGenerator();
    247         ilgen.Emit(OpCodes.Ldc_I4_1); // load true
     247        var local = ilgen.DeclareLocal(typeof(StorableConstructorFlag));
     248        ilgen.Emit(OpCodes.Ldloca_S, local);
     249        ilgen.Emit(OpCodes.Initobj,typeof(StorableConstructorFlag)); // load default value for StorableConstructorFlag
     250        ilgen.Emit(OpCodes.Ldloc_0);
    248251        ilgen.Emit(OpCodes.Newobj, ci);
    249252        ilgen.Emit(OpCodes.Ret);
Note: See TracChangeset for help on using the changeset viewer.