public IEnumerable <AvdDevice> ListDevices() { var r = new List <AvdDevice>(); var lines = run("list", "device"); var str = string.Join("\n", lines); var matches = rxListDevices.Matches(str); if (matches != null && matches.Count > 0) { foreach (Match m in matches) { var a = new AvdDevice { Name = m.Groups?["name"]?.Value, Id = m.Groups?["id"]?.Value, Oem = m.Groups?["oem"]?.Value }; if (!string.IsNullOrWhiteSpace(a.Name)) { r.Add(a); } } } return(r); }
public IEnumerable <AvdDevice> ListDevices() { var r = new List <AvdDevice>(); var lines = run("list", "device"); var str = string.Join("\n", lines); var matches = rxListDevices.Matches(str); if (matches != null && matches.Count > 0) { foreach (Match m in matches) { // Parse out the id further from: `18 or "pixel"` var idstr = m.Groups?["id"]?.Value; int?idnum = null; var idRx = rxIdOr.Match(idstr); if (idRx != null && idRx.Success && int.TryParse(idRx.Groups?["num"]?.Value, out var idInt)) { idnum = idInt; idstr = idRx.Groups?["str"]?.Value ?? idstr; } var a = new AvdDevice { Name = m.Groups?["name"]?.Value, Id = idstr, NumericId = idnum, Oem = m.Groups?["oem"]?.Value }; if (!string.IsNullOrWhiteSpace(a.Name)) { r.Add(a); } } } return(r); }