/// <summary> /// Gets the class name of the base class relevant for layout.xml. /// </summary> private static string GetLayoutBaseClassName(ClassFile classFile) { while (true) { var className = classFile.ClassName; switch (className) { case SdkConstants.ViewClass: case SdkConstants.ViewGroupClass: return className; case SdkConstants.ObjectClass: return null; } // Go to the base class if (!classFile.TryGetSuperClass(out classFile)) return null; } }
/// <summary> /// Is our <see cref="instanceOfCondition"/> a base class of the given type? /// </summary> private bool Extends(ClassFile javaClass) { while (javaClass != null) { if (javaClass.ClassName == className) return true; ClassFile superClass; if (!javaClass.TryGetSuperClass(out superClass)) return false; javaClass = superClass; } return false; }
/// <summary> /// Is our <see cref="instanceOfCondition"/> an interface implemented by the given type (or one of it's base types)? /// </summary> private bool Implements(ReachableContext context, ClassFile javaClass) { while (javaClass != null) { if (javaClass.ClassName == className) return true; if (javaClass.Interfaces != null) { foreach (var intfRef in javaClass.Interfaces) { ClassFile intf; if (context.TryLoadClass(intfRef.ClassName, out intf)) { if (Implements(context, intf)) return true; } } } ClassFile superClass; if (!javaClass.TryGetSuperClass(out superClass)) return false; javaClass = superClass; } return false; }
/// <summary> /// Try to resolve a type parameter in a base class. /// </summary> private NetTypeReference ResolveTypeParameterInBaseClass(ClassFile @class, string name, TargetFramework target) { ClassFile baseClass; while (@class.TryGetSuperClass(out baseClass)) { var signature = baseClass.Signature; if (signature != null) { var typeParam = signature.TypeParameters.FirstOrDefault(x => x.Name == name); if (typeParam != null) { var index = signature.TypeParameters.IndexOf(typeParam); var javaType = @class.Signature.SuperClass.Arguments.ElementAt(index).Signature; return javaType.Resolve(target, this, convertSignedBytes); } } @class = baseClass; } return null; }