Changeset 3010
- Timestamp:
- 03/12/10 10:43:08 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Persistence/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/StorableHookAttribute.cs
r2994 r3010 46 46 } 47 47 48 private static readonly BindingFlags instanceMembers =49 BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public ;48 private static readonly BindingFlags declaredInstanceMembers = 49 BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.DeclaredOnly; 50 50 51 51 private static readonly object[] emptyArgs = new object[] { }; … … 79 79 } 80 80 81 private static IEnumerable<MethodInfo> CollectHooks(HookType hookType, Type type) { 82 foreach (MemberInfo memberInfo in type.GetMembers(instanceMembers)) { 81 private static IEnumerable<MethodInfo> CollectHooks(HookType hookType, Type type) { 82 if (type.BaseType != null) 83 foreach (var mi in CollectHooks(hookType, type.BaseType)) 84 yield return mi; 85 foreach (MemberInfo memberInfo in type.GetMembers(declaredInstanceMembers)) { 83 86 foreach (StorableHookAttribute hook in memberInfo.GetCustomAttributes(typeof(StorableHookAttribute), false)) { 84 87 if (hook != null && hook.HookType == hookType) { -
trunk/sources/HeuristicLab.Persistence/3.3/Tests/UseCases.cs
r3005 r3010 784 784 } 785 785 786 [StorableClass(StorableClassType.MarkedOnly)] 787 public class HookInheritanceTestBase { 788 [Storable] 789 public object a; 790 public object link; 791 [StorableHook(HookType.AfterDeserialization)] 792 private void relink() { 793 link = a; 794 } 795 } 796 797 [StorableClass(StorableClassType.Empty)] 798 public class HookInheritanceTestDerivedClass : HookInheritanceTestBase { 799 [Storable] 800 public object b; 801 [StorableHook(HookType.AfterDeserialization)] 802 private void relink() { 803 Assert.AreSame(a, link); 804 link = b; 805 } 806 } 807 808 [TestMethod] 809 public void TestLinkInheritance() { 810 HookInheritanceTestDerivedClass c = new HookInheritanceTestDerivedClass(); 811 c.a = new object(); 812 XmlGenerator.Serialize(c, tempFile); 813 HookInheritanceTestDerivedClass newC = (HookInheritanceTestDerivedClass)XmlParser.Deserialize(tempFile); 814 Assert.AreSame(c.b, c.link); 815 } 816 786 817 [ClassInitialize] 787 818 public static void Initialize(TestContext testContext) {
Note: See TracChangeset
for help on using the changeset viewer.