/// <summary>
        /// Determines whether the specified <paramref name="unitOfWork"/> can be disposed.
        /// </summary>
        /// <param name="unitOfWork">The unit of work.</param>
        /// <returns>
        /// <c>true</c> if no <see cref="AmbientExists"/>; otherwise:
        /// <c>true</c> if the <see cref="AmbientUnitOfWorkDecorator.IsDisposable"/> and <paramref name="unitOfWork.Parent"/> is null; otherwise <c>false</c>
        /// </returns>
        /// <remarks></remarks>
        public virtual Boolean CanDisposeUnitOfWork(UnitOfWorkBase unitOfWork)
        {
            if (AmbientExists)
            {
                // Save the current disposable state of the ambient unit of work locally since further execution may affect it.
                var ambientIsDisposable = Ambient.IsDisposable;

                if (Ambient.Equals(unitOfWork))
                {
                    if (ambientIsDisposable)
                    {
                        AmbientUnitsOfWork.Pop();
                    }
                    else
                    {
                        Ambient.Decrement();
                    }
                }

                if ((unitOfWork.Status == TransactionStatus.Committed || unitOfWork.Status == TransactionStatus.Aborted) ||
                    (ambientIsDisposable && unitOfWork.Parent == null))
                {
                    return(true);
                }

                return(false);
            }

            return(true);
        }