public static Stream?FromJniHandle(IntPtr handle, JniHandleOwnership transfer)
        {
            if (handle == IntPtr.Zero)
            {
                return(null);
            }

            var inst = (IJavaObject?)Java.Lang.Object.PeekObject(handle);

            if (inst == null)
            {
                inst = (IJavaObject)Java.Interop.TypeManager.CreateInstance(handle, transfer);
            }
            else
            {
                JNIEnv.DeleteRef(handle, transfer);
            }

            return(new InputStreamInvoker((Java.IO.InputStream)inst));
        }
示例#2
0
        internal static Stream FromNative(IntPtr handle, JniHandleOwnership transfer)
        {
            if (handle == IntPtr.Zero)
            {
                return(null);
            }

            IJavaObject inst = Java.Lang.Object.PeekObject(handle);

            if (inst == null)
            {
                inst = Java.Interop.TypeManager.CreateInstance(handle, transfer);
            }
            else
            {
                JNIEnv.DeleteRef(handle, transfer);
            }

            return(new OutputStreamInvoker((Java.IO.OutputStream)inst));
        }
示例#3
0
        public static IList FromJniHandle(IntPtr handle, JniHandleOwnership transfer)
        {
            if (handle == IntPtr.Zero)
            {
                return(null);
            }

            IJavaObject inst = Java.Lang.Object.PeekObject(handle);

            if (inst == null)
            {
                inst = new JavaList(handle, transfer);
            }
            else
            {
                JNIEnv.DeleteRef(handle, transfer);
            }

            return((IList)inst);
        }
示例#4
0
        public static ICollection?FromJniHandle(IntPtr handle, JniHandleOwnership transfer)
        {
            if (handle == IntPtr.Zero)
            {
                return(null);
            }

            var inst = (IJavaObject?)Java.Lang.Object.PeekObject(handle);

            if (inst == null)
            {
                inst = new JavaSet(handle, transfer);
            }
            else
            {
                JNIEnv.DeleteRef(handle, transfer);
            }

            return((ICollection)inst);
        }