Exemplo n.º 1
0
    static int Main()
    {
        try{
            Console.WriteLine("Scenario 1 : Delegate marshaled as field in struct with Sequential.");
            Struct3_InterfacePtrAsField1_Seq sis = new Struct3_InterfacePtrAsField1_Seq();
            sis.verification = true;
            sis.dele         = new Dele2(CommonMethod1);
            sis.dele        += new Dele2(CommonMethod2);
            sis.dele        += new Dele2(CommonMethod3);
            Assert.IsTrue(Take_DelegatePtrAsFieldInStruct_Seq(sis), "Delegate marshaled as field in struct with Sequential.");

            Console.WriteLine("\n\nScenario 2 : Delegate marshaled as field in struct with Explicit.");
            Struct3_InterfacePtrAsField2_Exp sie = new Struct3_InterfacePtrAsField2_Exp();
            sie.verification = true;
            sie.dele         = new Dele2(CommonMethod1);
            sie.dele        += new Dele2(CommonMethod2);
            sie.dele        += new Dele2(CommonMethod3);
            Assert.IsTrue(Take_DelegatePtrAsFieldInStruct_Exp(sie), "Delegate marshaled as field in struct with Explicit.");

            Console.WriteLine("\n\nScenario 3 : Delegate marshaled as field in class with Sequential.");
            Class3_InterfacePtrAsField3_Seq cis = new Class3_InterfacePtrAsField3_Seq();
            cis.verification = true;
            cis.dele         = new Dele2(CommonMethod1);
            cis.dele        += new Dele2(CommonMethod2);
            cis.dele        += new Dele2(CommonMethod3);
            Assert.IsTrue(Take_DelegatePtrAsFieldInClass_Seq(cis), "Delegate marshaled as field in class with Sequential");

            Console.WriteLine("\n\nScenario 4 : Delegate marshaled as field in class with Sequential.");
            Class3_InterfacePtrAsField4_Exp cie = new Class3_InterfacePtrAsField4_Exp();
            cie.verification = true;
            cie.dele         = new Dele2(CommonMethod1);
            cie.dele        += new Dele2(CommonMethod2);
            cie.dele        += new Dele2(CommonMethod3);
            Assert.IsTrue(Take_DelegatePtrAsFieldInClass_Exp(cie), "Delegate marshaled as field in class with Sequential");

            return(100);
        } catch (Exception e) {
            Console.WriteLine($"Test Failure: {e}");
            return(101);
        }
    }
Exemplo n.º 2
0
 extern static bool Take_DelegatePtrAsFieldInStruct_Seq(Struct3_InterfacePtrAsField1_Seq sis);