SharpAdbClient.DeviceData.CreateFromAdbData C# (CSharp) Method

CreateFromAdbData() public static method

Creates a new instance of the DeviceData class based on data retrieved from the Android Debug Bridge.
public static CreateFromAdbData ( string data ) : DeviceData
data string /// The data retrieved from the Android Debug Bridge that represents a device. ///
return DeviceData
        public static DeviceData CreateFromAdbData(string data)
        {
            Regex re = new Regex(DeviceDataRegex, RegexOptions.Compiled | RegexOptions.IgnoreCase);
            Match m = re.Match(data);
            if (m.Success)
            {
                return new DeviceData()
                {
                    Serial = m.Groups["serial"].Value,
                    State = GetStateFromString(m.Groups["state"].Value),
                    Model = m.Groups["model"].Value,
                    Product = m.Groups["product"].Value,
                    Name = m.Groups["device"].Value,
                    Features = m.Groups["features"].Value
                };
            }
            else
            {
                throw new ArgumentException($"Invalid device list data '{data}'");
            }
        }

Usage Example

Example #1
0
        /// <summary>
        /// Processes the incoming device data.
        /// </summary>
        private void ProcessIncomingDeviceData(string result)
        {
            List <DeviceData> list = new List <DeviceData>();

            string[] deviceValues = result.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries);

            List <DeviceData> currentDevices = deviceValues.Select(d => DeviceData.CreateFromAdbData(d)).ToList();

            this.UpdateDevices(currentDevices);
        }
All Usage Examples Of SharpAdbClient.DeviceData::CreateFromAdbData