string CreateNamespaceCref(string jniTypeName) { string package = jniTypeName.Substring(0, jniTypeName.LastIndexOf('/')); package = package.Replace('/', '.'); if (Application.PackageRenames.ContainsKey(package)) { package = Application.PackageRenames [package]; } return("N:" + StringRocks.PackageToPascalCase(package)); }
public static GenBaseSupport CreateGenBaseSupport(XElement pkg, XElement elem, bool isInterface) { var support = new GenBaseSupport { IsAcw = true, IsDeprecated = elem.XGetAttribute("deprecated") != "not deprecated", IsGeneratable = true, JavaSimpleName = elem.XGetAttribute("name"), PackageName = pkg.XGetAttribute("name"), Visibility = elem.XGetAttribute("visibility") }; if (support.IsDeprecated) { support.DeprecatedComment = elem.XGetAttribute("deprecated"); if (support.DeprecatedComment == "deprecated") { support.DeprecatedComment = "This class is obsoleted in this android platform"; } } if (support.Visibility == "protected") { support.Visibility = "protected internal"; } if (pkg.Attribute("managedName") != null) { support.Namespace = pkg.XGetAttribute("managedName"); } else { support.Namespace = StringRocks.PackageToPascalCase(support.PackageName); } var tpn = elem.Element("typeParameters"); if (tpn != null) { support.TypeParameters = GenericParameterDefinitionList.FromXml(tpn); support.IsGeneric = true; int idx = support.JavaSimpleName.IndexOf('<'); if (idx > 0) { support.JavaSimpleName = support.JavaSimpleName.Substring(0, idx); } } else { int idx = support.JavaSimpleName.IndexOf('<'); if (idx > 0) { throw new NotSupportedException("Looks like old API XML is used, which we don't support anymore."); } } string raw_name; if (elem.Attribute("managedName") != null) { support.Name = elem.XGetAttribute("managedName"); support.FullName = string.Format("{0}.{1}", support.Namespace, support.Name); int idx = support.Name.LastIndexOf('.'); support.Name = idx > 0 ? support.Name.Substring(idx + 1) : support.Name; raw_name = support.Name; } else { int idx = support.JavaSimpleName.LastIndexOf('.'); support.Name = idx > 0 ? support.JavaSimpleName.Substring(idx + 1) : support.JavaSimpleName; if (char.IsLower(support.Name [0])) { support.Name = StringRocks.TypeToPascalCase(support.Name); } raw_name = support.Name; support.TypeNamePrefix = isInterface ? IsPrefixableName(raw_name) ? "I" : string.Empty : string.Empty; support.Name = EnsureValidIdentifer(support.TypeNamePrefix + raw_name); support.FullName = string.Format("{0}.{1}{2}", support.Namespace, idx > 0 ? StringRocks.TypeToPascalCase(support.JavaSimpleName.Substring(0, idx + 1)) : string.Empty, support.Name); } support.IsObfuscated = IsObfuscatedName(pkg.Elements().Count(), support.JavaSimpleName) && elem.XGetAttribute("obfuscated") != "false"; return(support); }
public XmlGenBaseSupport(XElement pkg, XElement elem) { deprecated = elem.XGetAttribute("deprecated") != "not deprecated"; if (deprecated) { deprecatedComment = elem.XGetAttribute("deprecated"); if (deprecatedComment == "deprecated") { deprecatedComment = "This class is obsoleted in this android platform"; } } visibility = elem.XGetAttribute("visibility"); if (visibility == "protected") { visibility = "protected internal"; } pkg_name = pkg.XGetAttribute("name"); java_name = elem.XGetAttribute("name"); if (pkg.Attribute("managedName") != null) { ns = pkg.XGetAttribute("managedName"); } else { ns = StringRocks.PackageToPascalCase(PackageName); } var tpn = elem.Element("typeParameters"); if (tpn != null) { type_params = GenericParameterDefinitionList.FromXml(tpn); is_generic = true; int idx = java_name.IndexOf('<'); if (idx > 0) { java_name = java_name.Substring(0, idx); } } else { int idx = java_name.IndexOf('<'); if (idx > 0) { throw new NotSupportedException("Looks like old API XML is used, which we don't support anymore."); } } if (elem.Attribute("managedName") != null) { name = elem.XGetAttribute("managedName"); full_name = String.Format("{0}.{1}", ns, name); int idx = name.LastIndexOf('.'); name = idx > 0 ? name.Substring(idx + 1) : name; raw_name = name; } else { int idx = java_name.LastIndexOf('.'); name = idx > 0 ? java_name.Substring(idx + 1) : java_name; if (Char.IsLower(name[0])) { name = StringRocks.TypeToPascalCase(name); } raw_name = name; name = TypeNamePrefix + raw_name; full_name = String.Format("{0}.{1}{2}", ns, idx > 0 ? StringRocks.TypeToPascalCase(java_name.Substring(0, idx + 1)) : String.Empty, name); } obfuscated = IsObfuscatedName(pkg.Elements().Count(), java_name) && elem.XGetAttribute("obfuscated") != "false"; }