public bool UpdateForNextAttempt()
        {
            _resultDto = null;

            var correlationId = Guid.NewGuid();
            Attempt += 1;
            var package = new TcpPackage(SentPackage.Command, correlationId, SentPackage.Data);
            SentPackage = package;

            return true;
        }
        public ProcessResult Process(TcpPackage package)
        {
            try
            {
                if (package.Command != TcpCommand.DeleteStreamCompleted)
                {
                    return new ProcessResult(ProcessResultStatus.NotifyError,
                                             new Exception(string.Format("Not expected command, expected {0}, received {1}",
                                                                         TcpCommand.DeleteStreamCompleted, package.Command)));
                }

                var data = package.Data;
                var dto = data.Deserialize<ClientMessageDto.DeleteStreamCompleted>();
                _resultDto = dto;

                switch ((OperationErrorCode)dto.ErrorCode)
                {
                    case OperationErrorCode.Success:
                        return new ProcessResult(ProcessResultStatus.Success);

                    case OperationErrorCode.PrepareTimeout:
                    case OperationErrorCode.CommitTimeout:
                    case OperationErrorCode.ForwardTimeout:
                        if (Attempt < MaxRetriesCount)
                        {
                            return new ProcessResult(ProcessResultStatus.Retry);
                        }
                        else
                        {
                            return new ProcessResult(ProcessResultStatus.NotifyError,
                                                     new Exception(string.Format("Max retries count reached, last error: {0}",
                                                                  (OperationErrorCode)dto.ErrorCode)));
                        }
                    case OperationErrorCode.WrongExpectedVersion:
                    case OperationErrorCode.StreamDeleted:
                    case OperationErrorCode.InvalidTransaction:
                        return new ProcessResult(ProcessResultStatus.NotifyError,
                                                 new Exception(string.Format("{0}", (OperationErrorCode)dto.ErrorCode)));
                    default:
                        throw new ArgumentOutOfRangeException();
                }
            }
            catch (Exception ex)
            {
                return new ProcessResult(ProcessResultStatus.NotifyError, ex);
            }
        }