Exemplo n.º 1
0
        void TestTypeConversion()
        {
            // Sanity checking to ensure that our binding stays correct.
            var v = ServerSocketFactory.Default;

            Log.Info("HelloApp", "ServerSocketFactory.Default={0}", v);
            var egl = EGLContext.EGL;

            Log.Info("HelloApp", "EGLContext.EGL={0}", egl);
            IEGL10 egl10 = egl.JavaCast <IEGL10>();

            Log.Info("HelloApp", "(IEGL10) EGLContext.EGL={0}", egl10.GetType().FullName);

            IntPtr lref = JNIEnv.NewString("Hello, world!");

            using (Java.Lang.Object s = Java.Lang.Object.GetObject <Java.Lang.Object>(lref, JniHandleOwnership.TransferLocalRef)) {
                if (s.GetType() != typeof(Java.Lang.String))
                {
                    throw new InvalidOperationException("Object.GetObject<T>() needs to return a Java.Lang.String!");
                }
            }

            lref = JNIEnv.CreateInstance("android/gesture/Gesture", "()V");
            using (Java.Lang.Object g = Java.Lang.Object.GetObject <Java.Lang.Object>(lref, JniHandleOwnership.TransferLocalRef))
                if (g.GetType() != typeof(Android.Gestures.Gesture))
                {
                    throw new InvalidOperationException("Object.GetObject<T>() needs to return a Android.Gestures.Gesture!");
                }
        }