Exemplo n.º 1
0
        public static int test_0_tests()
        {
            // Check that creation of delegates do not runs the class cctor
            DoIt doit = new DoIt(B.method);
            //
            //  Beginn Aenderung Test
            //
//		if (A.b_cctor_run)
//			return 1;
            //
            //  Ende Aenderung Test
            //
            Tests             test = new Tests();
            SimpleDelegate    d    = new SimpleDelegate(F);
            SimpleDelegate    d1   = new SimpleDelegate(test.VF);
            NotSimpleDelegate d2   = new NotSimpleDelegate(G);
            NotSimpleDelegate d3   = new NotSimpleDelegate(test.H);

            d();
            d1();
            // we run G() and H() before and after using them as delegates
            // to be sure we don't corrupt them.
            G(2);
            test.H(3);
            Console.WriteLine(d2(2));
            Console.WriteLine(d3(3));
            G(2);
            test.H(3);

            if (d.Method.Name != "F")
            {
                return(1);
            }

            if (d3.Method == null)
            {
                return(1);
            }

            object [] args = { 3 };
            Console.WriteLine(d3.DynamicInvoke(args));

            AnotherDelegate d4 = new AnotherDelegate(puts);

            if (d4.Method == null)
            {
                return(1);
            }

            Console.WriteLine(d4.Method);
            Console.WriteLine(d4.Method.Name);
            Console.WriteLine(d4.Method.DeclaringType);

            return(0);
        }
Exemplo n.º 2
0
	public static int test_0_tests () {
		// Check that creation of delegates do not runs the class cctor
		DoIt doit = new DoIt (B.method);
		if (A.b_cctor_run)
			return 1;

		Tests test = new Tests ();
		SimpleDelegate d = new SimpleDelegate (F);
		SimpleDelegate d1 = new SimpleDelegate (test.VF);
		NotSimpleDelegate d2 = new NotSimpleDelegate (G);
		NotSimpleDelegate d3 = new NotSimpleDelegate (test.H);
		d ();
		d1 ();
		// we run G() and H() before and after using them as delegates
		// to be sure we don't corrupt them.
		G (2);
		test.H (3);
		Console.WriteLine (d2 (2));
		Console.WriteLine (d3 (3));
		G (2);
		test.H (3);

		if (d.Method.Name != "F")
			return 1;

		if (d3.Method == null)
			return 1;
		
		object [] args = {3};
		Console.WriteLine (d3.DynamicInvoke (args));

		AnotherDelegate d4 = new AnotherDelegate (puts);
		if (d4.Method == null)
			return 1;

		Console.WriteLine (d4.Method);
		Console.WriteLine (d4.Method.Name);
		Console.WriteLine (d4.Method.DeclaringType);
		
		return 0;
	}
Exemplo n.º 3
0
 public static int test_0_tests()
 {
     DoIt
     doit
     =
     new
     DoIt
     (B.method);
     if
     (A.b_cctor_run)
     return
     1;
     Tests
     test
     =
     new
     Tests
     ();
     SimpleDelegate
     d
     =
     new
     SimpleDelegate
     (F);
     SimpleDelegate
     d1
     =
     new
     SimpleDelegate
     (test.VF);
     NotSimpleDelegate
     d2
     =
     new
     NotSimpleDelegate
     (G);
     NotSimpleDelegate
     d3
     =
     new
     NotSimpleDelegate
     (test.H);
     d
     ();
     d1
     ();
     G
     (2);
     test.H
     (3);
     Console.WriteLine
     (d2
     (2));
     Console.WriteLine
     (d3
     (3));
     G
     (2);
     test.H
     (3);
     if
     (d.Method.Name
     !=
     "F")
     return
     1;
     if
     (d3.Method
     ==
     null)
     return
     1;
     object
     []
     args
     =
     {3};
     Console.WriteLine
     (d3.DynamicInvoke
     (args));
     AnotherDelegate
     d4
     =
     new
     AnotherDelegate
     (puts);
     if
     (d4.Method
     ==
     null)
     return
     1;
     Console.WriteLine
     (d4.Method);
     Console.WriteLine
     (d4.Method.Name);
     Console.WriteLine
     (d4.Method.DeclaringType);
     return
     0;
 }