public static int Main(string[] args)
 {
     try
     {
         float width  = 1.0f;
         float height = 2.0f;
         StdCallMemberFunctionNative.C *instance = StdCallMemberFunctionNative.CreateInstanceOfC(width, height);
         Test8ByteHFA(instance);
         Test4ByteHFA(instance);
         Test4ByteNonHFA(instance);
         TestEnum(instance);
         TestCLong(instance);
         Test8ByteHFAUnmanagedCallersOnly();
         Test4ByteHFAUnmanagedCallersOnly();
         Test4ByteNonHFAUnmanagedCallersOnly();
         TestEnumUnmanagedCallersOnly();
         TestCLongUnmanagedCallersOnly();
     }
     catch (System.Exception ex)
     {
         Console.WriteLine(ex);
         return(101);
     }
     return(100);
 }
    private static void TestCLongUnmanagedCallersOnly()
    {
        StdCallMemberFunctionNative.C c = CreateCWithUnmanagedCallersOnlyVTable(2.0f, 3.0f);
        CLong result = StdCallMemberFunctionNative.GetWidthAsLongFromManaged(&c);

        Assert.AreEqual((nint)c.width, result.Value);
    }
    private static void TestEnumUnmanagedCallersOnly()
    {
        StdCallMemberFunctionNative.C c      = CreateCWithUnmanagedCallersOnlyVTable(2.0f, 3.0f);
        StdCallMemberFunctionNative.E result = StdCallMemberFunctionNative.GetEFromManaged(&c);

        Assert.AreEqual(c.dummy, result);
    }
    private static void Test4ByteNonHFAUnmanagedCallersOnly()
    {
        StdCallMemberFunctionNative.C          c      = CreateCWithUnmanagedCallersOnlyVTable(2.0f, 3.0f);
        StdCallMemberFunctionNative.IntWrapper result = StdCallMemberFunctionNative.GetHeightAsIntFromManaged(&c);

        Assert.AreEqual((int)c.height, result.i);
    }
    private static void Test4ByteHFAUnmanagedCallersOnly()
    {
        StdCallMemberFunctionNative.C     c      = CreateCWithUnmanagedCallersOnlyVTable(2.0f, 3.0f);
        StdCallMemberFunctionNative.Width result = StdCallMemberFunctionNative.GetWidthFromManaged(&c);

        Assert.AreEqual(c.width, result.width);
    }
Exemple #6
0
    private static void Test8ByteHFAUnmanagedCallersOnly()
    {
        StdCallMemberFunctionNative.C     c      = CreateCWithUnmanagedCallersOnlyVTable(2.0f, 3.0f);
        StdCallMemberFunctionNative.SizeF result = StdCallMemberFunctionNative.GetSizeFromManaged(&c);

        Assert.Equal(c.width, result.width);
        Assert.Equal(c.height, result.height);
    }