Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/17/11 17:16:33 (14 years ago)
Author:
epitzer
Message:

check hooks by method name only (#1530)

Location:
branches/PersistenceSpeedUp/HeuristicLab.Persistence/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/PersistenceSpeedUp/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/StorableClassAnalyzer.cs

    r6224 r6228  
    139139      if (methodInfo.ReturnType != typeof(void) || methodInfo.GetParameters().Length > 0)
    140140        return;
    141       var attribute = (StorableHookAttribute)methodInfo.GetCustomAttributes(typeof(StorableHookAttribute), false).SingleOrDefault();
    142       if (attribute != null)
    143         typeDescriptor.Hooks.Add(new HookDescriptor(typeDescriptor, methodInfo, attribute.HookType));
     141      switch (methodInfo.Name) {
     142        case "AfterDeserialization":
     143          typeDescriptor.Hooks.Add(new HookDescriptor(typeDescriptor, methodInfo, HookType.AfterDeserialization));
     144          break;
     145        case "BeforeSerialization":
     146          typeDescriptor.Hooks.Add(new HookDescriptor(typeDescriptor, methodInfo, HookType.BeforeSerialization));
     147          break;
     148        default: break;
     149      }
    144150    }
    145151  }
  • branches/PersistenceSpeedUp/HeuristicLab.Persistence/3.3/Tests/UseCases.cs

    r6224 r6228  
    798798      public bool WasSerialized { get; private set; }
    799799      [StorableHook(HookType.BeforeSerialization)]
    800       void PreSerializationHook() {
     800      void BeforeSerialization() {
    801801        WasSerialized = true;
    802802      }
    803803      [StorableHook(HookType.AfterDeserialization)]
    804       void PostDeserializationHook() {
     804      void AfterDeserialization() {
    805805        sum = a + b;
    806806      }
     
    896896      public object link;
    897897      [StorableHook(HookType.AfterDeserialization)]
    898       private void relink() {
     898      private void AfterDeserialization() {
    899899        link = a;
    900900      }
     
    906906      public object b;
    907907      [StorableHook(HookType.AfterDeserialization)]
    908       private void relink() {
     908      private void AfterDeserialization() {
    909909        Assert.AreSame(a, link);
    910910        link = b;
Note: See TracChangeset for help on using the changeset viewer.