private ICommunicationMessage TranslateMessage(IStoreV1CommunicationData message) { if (!m_Converters.ContainsKey(message.GetType())) { return(new UnknownMessageTypeMessage(message.Sender, message.InResponseTo)); } var converter = m_Converters[message.GetType()]; return(converter.ToMessage(message)); }
private void SendMessage(IStoreV1CommunicationData message, int retryCount) { var count = 0; Exception exception = null; while (count < retryCount) { EnsureChannelIsAvailable(); exception = null; try { var service = m_Service; if (!m_IsDisposed) { var confirmation = service.AcceptMessage(message); if ((m_Channel.State == CommunicationState.Opened) && (confirmation != null) && confirmation.WasDataReceived) { return; } } } catch (FaultException e) { m_Diagnostics.Log( LevelToLog.Error, CommunicationConstants.DefaultLogTextPrefix, string.Format( CultureInfo.InvariantCulture, "Exception occurred during the sending of message of type {0}. Exception was: {1}", message.GetType(), e)); // If there is no inner exception then there is no point in keeping the original call stack. // The originalexception orginates on the other side of the channel which means that there is no // useful stack trace to keep! m_WasFaulted = true; exception = e.InnerException != null ? new FailedToSendMessageException(Resources.Exceptions_Messages_FailedToSendMessage, e.InnerException) : new FailedToSendMessageException(); } catch (CommunicationException e) { // Either the connection was aborted or faulted (although it shouldn't be) // or something else nasty went wrong. m_WasFaulted = true; exception = new FailedToSendMessageException(Resources.Exceptions_Messages_FailedToSendMessage, e); } count++; } if ((m_Channel.State != CommunicationState.Opened) && (exception == null)) { exception = new FailedToSendMessageException(); } if (exception != null) { throw exception; } }