public static Size GetSizeHook(Func <StructMagicTest, Size> orig, StructMagicTest self) { Assert.True(IsHook); IsHook = false; Size s = orig(self); IsHook = true; s.Width *= 10D; s.Height *= 10D; return(s); }
public void TestInstanceMethodReturnStruct() { GetStructInstance = this; IsHook = false; GetStructCounter = 0; GetStruct((IntPtr)100); Assert.Equal(100, GetStructCounter); using (new Hook( typeof(StructMagicTest).GetMethod("GetStruct"), typeof(StructMagicTest).GetMethod("GetStructHook") )) { IsHook = true; GetStructCounter = 600; GetStruct((IntPtr)100); Assert.Equal(1100, GetStructCounter); } }
public static SomeOtherStruct GetStructHook(Func <StructMagicTest, IntPtr, SomeOtherStruct> orig, StructMagicTest self, IntPtr x) { Assert.True(IsHook); IsHook = false; SomeOtherStruct s = orig(self, x); IsHook = true; self.GetStructCounter += 400; return(s); }