示例#1
0
 //
 // Exception audit:
 //
 //  Verdict
 //    Exception wrapping is required.
 //
 //  Rationale
 //    `java.util.Set.contains(Object)` throws a number of exceptions, see:
 //
 //     https://developer.android.com/reference/java/util/Set?hl=en#contains(java.lang.Object)
 //
 public bool Contains(object item)
 {
     if (id_contains == IntPtr.Zero)
     {
         id_contains = JNIEnv.GetMethodID(set_class, "contains", "(Ljava/lang/Object;)Z");
     }
     return(JavaConvert.WithLocalJniHandle(item, lref => {
         try {
             return JNIEnv.CallBooleanMethod(Handle, id_contains, new JValue(lref));
         } catch (Java.Lang.ClassCastException ex) when(JNIEnv.ShouldWrapJavaException(ex))
         {
             throw new InvalidCastException(ex.Message, ex);
         } catch (Java.Lang.NullPointerException ex) when(JNIEnv.ShouldWrapJavaException(ex))
         {
             throw new NullReferenceException(ex.Message, ex);
         }
     }));
 }
示例#2
0
 //
 // Exception audit:
 //
 //  Verdict
 //    Exception wrapping is required.
 //
 //  Rationale
 //    `java.util.Set.remove(Object)` throws a number of exceptions, see:
 //
 //     https://developer.android.com/reference/java/util/Set?hl=en#remove(java.lang.Object)
 //
 public void Remove(object item)
 {
     if (id_remove == IntPtr.Zero)
     {
         id_remove = JNIEnv.GetMethodID(set_class, "remove", "(Ljava/lang/Object;)Z");
     }
     JavaConvert.WithLocalJniHandle(item, lref => {
         try {
             return(JNIEnv.CallBooleanMethod(Handle, id_remove, new JValue(lref)));
         } catch (Java.Lang.UnsupportedOperationException ex) when(JNIEnv.ShouldWrapJavaException(ex))
         {
             throw new NotSupportedException(ex.Message, ex);
         } catch (Java.Lang.ClassCastException ex) when(JNIEnv.ShouldWrapJavaException(ex))
         {
             throw new InvalidCastException(ex.Message, ex);
         } catch (Java.Lang.NullPointerException ex) when(JNIEnv.ShouldWrapJavaException(ex))
         {
             throw new NullReferenceException(ex.Message, ex);
         }
     });
 }