示例#1
0
        public static IDevice[] CollectIOSDevices()
        {
            var json = RunCmd("list --json");

            if (string.IsNullOrEmpty(json))
            {
                return(Array.Empty <IDevice>());
            }
            try {
                var       deviceDataArray = JArray.Parse(json);
                IDevice[] devices         = new IDevice[deviceDataArray.Count];
                for (int i = 0; i < deviceDataArray.Count; i++)
                {
                    var deviceData = deviceDataArray[i] as JObject;
                    var udid       = deviceData["udid"].ToString();
                    var name       = deviceData["name"].ToString();
                    devices[i] = new IOSDevice(udid, name);
                }

                return(devices);
            }
            catch (Exception) {
                return(new IDevice[0]);
            }
        }
示例#2
0
        private void RefreshDevice()
        {
            if (string.IsNullOrEmpty(GlobalData.Instance.AdbPath))
            {
                return;
            }
            GlobalData.Instance.Devices = AndroidDevice.CollectAndroidDevices();
            GlobalData.Instance.Devices = Concatenate(GlobalData.Instance.Devices, IOSDevice.CollectIOSDevices());

            if (GlobalData.Instance.Devices.Length > 0)
            {
                GlobalData.Instance.SelectedDevice = GlobalData.Instance.Devices[0];
            }
        }