internal static Type GetJavaToManagedType(string class_name) { var t = monodroid_typemap_java_to_managed(class_name); if (t != IntPtr.Zero) { return(Type.GetType(Marshal.PtrToStringAnsi(t))); } var type = (Type)null; int ls = class_name.LastIndexOf('/'); var package = ls >= 0 ? class_name.Substring(0, ls) : ""; List <Converter <string, Type> > mappers; if (packageLookup.TryGetValue(package, out mappers)) { foreach (Converter <string, Type> c in mappers) { type = c(class_name); if (type == null) { continue; } return(type); } } if ((type = Type.GetType(JniTypeMapping.ToCliType(class_name))) != null) { return(type); } return(null); }
public static void RegisterType(string java_class, Type t) { string jniFromType = JniTypeMapping.ToJniName(t); lock (jniToManaged) { Type lookup; if (!jniToManaged.TryGetValue(java_class, out lookup)) { jniToManaged.Add(java_class, t); if (jniFromType != java_class) { managedToJni.Add(t, java_class); } } else if (!JNIEnv.IsRunningOnDesktop || t != typeof(Java.Interop.TypeManager)) { // skip the registration and output a warning Logger.Log(LogLevel.Warn, "monodroid", string.Format("Type Registration Skipped for {0} to {1} ", java_class, t.ToString())); } } }