Changeset 3554 for trunk/sources/HeuristicLab.Persistence/3.3/Default
- Timestamp:
- 04/28/10 14:19:57 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/StorableReflection.cs
r3553 r3554 51 51 } 52 52 53 private static object[] emptyArgs = new object[0]; 54 53 55 public static IEnumerable<Hook> CollectHooks(HookType hookType, Type type) { 54 56 if (type.BaseType != null) … … 60 62 MethodInfo methodInfo = memberInfo as MethodInfo; 61 63 if (memberInfo.MemberType != MemberTypes.Method || memberInfo == null) 62 throw new ArgumentException("Storable hooks must be methods"); 63 DynamicMethod dm = new DynamicMethod("", null, new[] { typeof(object) }, type); 64 ILGenerator ilgen = dm.GetILGenerator(); 65 ilgen.Emit(OpCodes.Ldarg_1); 66 ilgen.Emit(OpCodes.Call, methodInfo); 67 ilgen.Emit(OpCodes.Ret); 68 yield return (Hook)dm.CreateDelegate(typeof(Hook)); 64 throw new ArgumentException("Storable hooks must be methods"); 65 if (System.IntPtr.Size == 4) { 66 DynamicMethod dm = new DynamicMethod("", null, new[] { typeof(object) }, type); 67 ILGenerator ilgen = dm.GetILGenerator(); 68 ilgen.Emit(OpCodes.Ldarg_1); 69 ilgen.Emit(OpCodes.Call, methodInfo); 70 ilgen.Emit(OpCodes.Ret); 71 yield return (Hook)dm.CreateDelegate(typeof(Hook)); 72 } else { 73 yield return new Hook(o => methodInfo.Invoke(o, emptyArgs)); 74 } 69 75 } 70 76 }
Note: See TracChangeset
for help on using the changeset viewer.