/// <summary>
        /// Tries to get a given <see cref="TTransfer"/> from the internal
        /// cache.
        /// </summary>
        /// <param name="transferId">The identifier of the transfer, according to the corresponding
        /// <see cref="TransferToken.TransferId"/>.</param>
        /// <param name="throwExceptionIfNotFound">If true, a <see cref="UnknownTransferException"/>
        /// is thrown if no matching transfer was found in the cache.</param>
        /// <param name="context">The file system operation that is being performed during the invocation of
        /// this method. Used for internal auditing.</param>
        /// <returns>Either the matching transfer, or null, if no match was found *and*
        /// <paramref name="throwExceptionIfNotFound"/> is false.</returns>
        protected virtual TTransfer GetCachedTransfer(string transferId, bool throwExceptionIfNotFound, FileSystemTask context)
        {
            TTransfer transfer = TransferStore.TryGetTransfer(transferId);

            if (transfer == null && throwExceptionIfNotFound)
            {
                Auditor.AuditUnknownTransferRequest(context, transferId);

                string msg = String.Format("Unknown transfer ID: {0}.", transferId);
                throw new UnknownTransferException(msg)
                      {
                          IsAudited = true, EventId = (int)AuditEvent.UnknownTransferRequest
                      };
            }

            return(transfer);
        }