public static CreateFromAdbData ( string data ) : |
||
data | string | /// The data retrieved from the Android Debug Bridge that represents a device. /// |
return |
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}'");
}
}
/// <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); }