private static ClipboardTimeoutException GetTimeOutException(IClipboardOperationResult result) { if (result == null) { throw new ArgumentNullException(nameof(result)); } if (result.IsSuccessful) { throw new ArgumentException($"{nameof(result)} is successful."); } var message = string.IsNullOrEmpty(result.Message) ? "Connection has been time out without being able to connect to the windows clipboard." : result.Message; if (result.LastError.HasValue) { var exception = new ClipboardWindowsApiException(result.LastError.Value); return(new ClipboardTimeoutException ( message, exception )); } if (result.LastErrors?.Any() == true) { var innerExceptions = result.LastErrors.Select(e => new ClipboardWindowsApiException(e)); throw new ClipboardTimeoutException(message, innerExceptions); } return(new ClipboardTimeoutException(message)); }
/// <exception cref="ClipboardWindowsApiException">Communication with windows API's has failed.</exception> private static void ThrowIfNotSuccessful(IClipboardOperationResult result) { if (!result.IsSuccessful) { var message = result.ResultCode.ToString(); if (result.LastError.HasValue) { throw new ClipboardWindowsApiException(result.LastError.Value, message); } throw new ClipboardWindowsApiException(message); } }
private ClipboardWindowsApiException GetException(IClipboardOperationResult result) { var message = string.IsNullOrEmpty(result.Message) ? "Connection to the clipboard could not be established." : result.Message; if (result.LastError.HasValue) { return(new ClipboardWindowsApiException(result.LastError.Value, message)); } return(new ClipboardWindowsApiException(message)); }
private ClipboardWindowsApiException GetException(IClipboardOperationResult result) { return(result.LastError.HasValue ? new ClipboardWindowsApiException(result.LastError.Value) : new ClipboardWindowsApiException("Connection to the clipboard could not be established.")); }