}
}
+ internal struct RuntimeEventHandle {
+ IntPtr value;
+
+ internal RuntimeEventHandle (IntPtr v)
+ {
+ value = v;
+ }
+
+ public IntPtr Value {
+ get {
+ return value;
+ }
+ }
+
+ public override bool Equals (object obj)
+ {
+ if (obj == null || GetType () != obj.GetType ())
+ return false;
+
+ return value == ((RuntimeEventHandle)obj).Value;
+ }
+
+ public bool Equals (RuntimeEventHandle handle)
+ {
+ return value == handle.Value;
+ }
+
+ public override int GetHashCode ()
+ {
+ return value.GetHashCode ();
+ }
+
+ public static bool operator == (RuntimeEventHandle left, RuntimeEventHandle right)
+ {
+ return left.Equals (right);
+ }
+
+ public static bool operator != (RuntimeEventHandle left, RuntimeEventHandle right)
+ {
+ return !left.Equals (right);
+ }
+ }
+
internal struct RuntimeGPtrArrayHandle {
unsafe RuntimeStructs.GPtrArray* value;
//
using System.Diagnostics;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace System.Reflection {
public virtual MethodInfo RemoveMethod {
get { return GetRemoveMethod (true); }
}
+
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ private static extern EventInfo internal_from_handle_type (IntPtr event_handle, IntPtr type_handle);
+
+ internal static EventInfo GetEventFromHandle (Mono.RuntimeEventHandle handle)
+ {
+ if (handle.Value == IntPtr.Zero)
+ throw new ArgumentException ("The handle is invalid.");
+ return internal_from_handle_type (handle.Value, IntPtr.Zero);
+ }
+
+ internal static EventInfo GetEventFromHandle (Mono.RuntimeEventHandle handle, RuntimeTypeHandle reflectedType)
+ {
+ if (handle.Value == IntPtr.Zero)
+ throw new ArgumentException ("The handle is invalid.");
+ EventInfo ei = internal_from_handle_type (handle.Value, reflectedType.Value);
+ if (ei == null)
+ throw new ArgumentException ("The event handle and the type handle are incompatible.");
+ return ei;
+ }
}
}
ICALL(TYPEB_6, "setup_generic_class", mono_reflection_setup_generic_class)
ICALL(TYPEB_7, "setup_internal_class", mono_reflection_setup_internal_class)
+ICALL_TYPE(EVENTI, "System.Reflection.EventInfo", EVENTI_1)
+ICALL(EVENTI_1, "internal_from_handle_type", ves_icall_System_Reflection_EventInfo_internal_from_handle_type)
+
ICALL_TYPE(FIELDI, "System.Reflection.FieldInfo", FILEDI_1)
ICALL(FILEDI_1, "GetTypeModifiers", ves_icall_System_Reflection_FieldInfo_GetTypeModifiers)
ICALL(FILEDI_2, "get_marshal_info", ves_icall_System_Reflection_FieldInfo_get_marshal_info)
return result;
}
+ICALL_EXPORT MonoReflectionEvent*
+ves_icall_System_Reflection_EventInfo_internal_from_handle_type (MonoEvent *handle, MonoType *type)
+{
+ MonoError error;
+ MonoClass *klass;
+
+ g_assert (handle);
+
+ if (!type) {
+ klass = handle->parent;
+ } else {
+ klass = mono_class_from_mono_type (type);
+
+ gboolean found = klass == handle->parent || mono_class_has_parent (klass, handle->parent);
+ if (!found)
+ /* Managed code will throw an exception */
+ return NULL;
+ }
+
+ MonoReflectionEvent *result = mono_event_get_object_checked (mono_domain_get (), klass, handle, &error);
+ mono_error_set_pending_exception (&error);
+ return result;
+}
+
ICALL_EXPORT MonoArray*
ves_icall_System_Reflection_FieldInfo_GetTypeModifiers (MonoReflectionField *field, MonoBoolean optional)
{