public void Send(PortableDevice device) { device.SendCommand(0, this.values, out this.result); int error = 0; result.GetErrorValue(WPD.PROPERTY_COMMON_HRESULT, out error); switch ((HResult)error) { case HResult.S_OK: return; case HResult.E_NOT_IMPLEMENTED: throw new NotSupportedException($"{new StackFrame(1, true).GetMethod().Name} not supported by device"); default: throw new Exception($"Error {error:X}"); } }
public bool Send(PortableDevice device) { device.SendCommand(0, this.values, out this.result); int error = 0; result.GetErrorValue(WPD.PROPERTY_COMMON_HRESULT, out error); switch ((HResult)error) { case HResult.S_OK: return(true); case HResult.E_NOT_IMPLEMENTED: return(false); default: throw new Exception($"Error {error:X}"); } }