コード例 #1
0
    public void Test()
    {
        Type typeA = typeof(PropClassA);
        Type typeB = typeof(PropClassB);

        PropertyInfo pi     = typeA.GetProperty("X");
        MethodInfo   miASet = pi.GetSetMethod();

        MethodInfo miBReplace = typeB.GetMethod("PropXSetReplace");
        MethodInfo miBProxy   = typeB.GetMethod("PropXSetProxy");

        if (miBProxy == null)
        {
            throw new Exception("PropXSetProxy is null");
        }

        MethodHook hook = new MethodHook(miASet, miBReplace, miBProxy);

        hook.Install();

        PropClassA a = new PropClassA(5);

        a.X = 7;
        Debug.Assert(a.X == 8);

        a.X = 100;
        Debug.Assert(a.X == 101);
    }
コード例 #2
0
    public static void PropXSetReplace(PropClassA a, int val)
    {
        Debug.LogFormat("PropXSetReplace with value:{0}", val);

        val += 1;
        PropXSetProxy(a, val);
    }
コード例 #3
0
    public void Test()
    {
        Type typeA = typeof(PropClassA);
        Type typeB = typeof(PropClassB);

        PropertyInfo pi     = typeA.GetProperty("X");
        MethodInfo   miASet = pi.GetSetMethod();

        MethodInfo miBReplace = typeB.GetMethod("PropXSetReplace");
        MethodInfo miBProxy   = typeB.GetMethod("PropXSetProxy");

        MethodHooker hooker = new MethodHooker(miASet, miBReplace, miBProxy);

        hooker.Install();

        PropClassA a = new PropClassA(5);

        a.X = 7;
        Debug.Assert(a.X == 8);
    }
コード例 #4
0
 public static void PropXSetProxy(PropClassA a, int val)
 {
 }