/// <summary> /// Called when a report should be send to the remote server. /// </summary> /// <param name="feedbackSender">The object that sends the report to the remote server.</param> /// <param name="feedbackReport">A stream that contains a feedback report.</param> private static void OnSendReport(ISendFeedbackReports feedbackSender, Stream feedbackReport) { if (feedbackSender == null) { return; } if (feedbackReport == null) { return; } try { feedbackSender.Send(feedbackReport); } catch (UnauthorizedAccessException) { // Ignore it and move on. } catch (IOException) { // Ignore it and move on. } catch (FailedToSendFeedbackReportException) { // Ignore it and move on. } }
/// <summary> /// Initializes a new instance of the <see cref="SendFeedbackReportCommand"/> class. /// </summary> /// <param name="feedbackSender"> /// The object that is responsible for sending reports to the remote server. /// </param> public SendFeedbackReportCommand(ISendFeedbackReports feedbackSender) : base( obj => OnSendReport(feedbackSender, obj as Stream), obj => CanSendReport(feedbackSender, obj as Stream)) { }
private static bool CanSendReport(ISendFeedbackReports feedbackSender, Stream feedbackReport) { return((feedbackSender != null) && (feedbackReport != null)); }