AndroidVersion ToAndroidVersion(string file)
        {
            var info    = XDocument.Load(file);
            var id      = (string)info.Root.Element("Id");
            var level   = (int)info.Root.Element("Level");
            var name    = (string)info.Root.Element("Name");
            var version = (string)info.Root.Element("Version");
            var stable  = (bool)info.Root.Element("Stable");
            var pver    = version.TrimStart('v');
            var v       = new AndroidVersion(level, pver, name, Version.Parse(pver), version, stable)
            {
                Id = id,
            };

            return(v);
        }
 void ReadAndroidVersions()
 {
     foreach (var frameworkDirectory in FrameworkDirectories)
     {
         foreach (var file in Directory.EnumerateFiles(frameworkDirectory, "AndroidApiInfo.xml", SearchOption.AllDirectories))
         {
             try {
                 var v = ToAndroidVersion(file);
                 installedVersions.Add(v);
                 if (MaxStableVersion == null || (v.Stable && MaxStableVersion.Version < v.Version))
                 {
                     MaxStableVersion = v;
                 }
             }
             catch (Exception e) {
                 AndroidLogger.LogError(message: $"Could not create AndroidVersion information for `{file}`.", ex: e);
             }
         }
     }
 }
 static bool MatchesId(AndroidVersion version, string id)
 {
     return(version.Id == id ||
            (version.AlternateIds?.Contains(id) ?? false) ||
            (version.ApiLevel.ToString() == id));
 }