Exemplo n.º 1
0
        public void Put(string key, short value)
        {
            if (id_put_Ljava_lang_String_Ljava_lang_Short_ == IntPtr.Zero)
            {
                id_put_Ljava_lang_String_Ljava_lang_Short_ = JNIEnv.GetMethodID(class_ref, "put", "(Ljava/lang/String;Ljava/lang/Short;)V");
            }
            IntPtr jkey = JNIEnv.NewString(key);

            try {
                using (var val = new Java.Lang.Short(value))
                    JNIEnv.CallVoidMethod(Handle, id_put_Ljava_lang_String_Ljava_lang_Short_, new JValue(jkey), new JValue(val));
            } finally {
                JNIEnv.DeleteLocalRef(jkey);
            }
        }
Exemplo n.º 2
0
        public short GetAsShort(string key)
        {
            if (id_getAsShort_Ljava_lang_String_ == IntPtr.Zero)
            {
                id_getAsShort_Ljava_lang_String_ = JNIEnv.GetMethodID(class_ref, "getAsShort", "(Ljava/lang/String;)Ljava/lang/Short;");
            }
            IntPtr jkey = JNIEnv.NewString(key);

            try {
                using (var ret = new Java.Lang.Short(JNIEnv.CallObjectMethod(Handle, id_getAsShort_Ljava_lang_String_, new JValue(jkey)),
                                                     JniHandleOwnership.TransferLocalRef | JniHandleOwnership.DoNotRegister))
                    return((short)ret);
            } finally {
                JNIEnv.DeleteLocalRef(jkey);
            }
        }
Exemplo n.º 3
0
 public void Put(string key, short value)
 {
     if (id_put_Ljava_lang_String_Ljava_lang_Short_ == IntPtr.Zero)
         id_put_Ljava_lang_String_Ljava_lang_Short_ = JNIEnv.GetMethodID (class_ref, "put", "(Ljava/lang/String;Ljava/lang/Short;)V");
     IntPtr jkey = JNIEnv.NewString (key);
     try {
         using (var val = new Java.Lang.Short (value))
             JNIEnv.CallVoidMethod (Handle, id_put_Ljava_lang_String_Ljava_lang_Short_, new JValue (jkey), new JValue (val));
     } finally {
         JNIEnv.DeleteLocalRef (jkey);
     }
 }
Exemplo n.º 4
0
 public short GetAsShort(string key)
 {
     if (id_getAsShort_Ljava_lang_String_ == IntPtr.Zero)
         id_getAsShort_Ljava_lang_String_ = JNIEnv.GetMethodID (class_ref, "getAsShort", "(Ljava/lang/String;)Ljava/lang/Short;");
     IntPtr jkey = JNIEnv.NewString (key);
     try {
         using (var ret = new Java.Lang.Short (JNIEnv.CallObjectMethod (Handle, id_getAsShort_Ljava_lang_String_, new JValue (jkey)),
                 JniHandleOwnership.TransferLocalRef | JniHandleOwnership.DoNotRegister))
             return (short) ret;
     } finally {
         JNIEnv.DeleteLocalRef (jkey);
     }
 }