internal static DeviceState GetStateFromString(string state)
{
// Default to the unknown state
DeviceState value = DeviceState.Unknown;
if (string.Equals(state, "device", StringComparison.OrdinalIgnoreCase))
{
// As a special case, the "device" state in ADB is translated to the
// "Online" state in Managed.Adb
value = DeviceState.Online;
}
else if (string.Equals(state, "no permissions", StringComparison.OrdinalIgnoreCase))
{
value = DeviceState.NoPermissions;
}
else
{
// Else, we try to match a value of the DeviceState enumeration.
if (!Enum.TryParse<DeviceState>(state, true, out value))
{
value = DeviceState.Unknown;
}
}
return value;
}
}