public void Enlist(ITwoPhaseUnitOfWork unitOfWork)
        {
            var n = new SinglePhaseEnlistmentNotification(this, unitOfWork);

            if (!Enlisted.TryAdd(unitOfWork, n))
            {
                throw new InvalidOperationException($"UnitOfWork already enlisted: {unitOfWork}");
            }
            Transaction.EnlistVolatile(n, EnlistmentOptions.EnlistDuringPrepareRequired);
        }
 public TwoPhaseAsUnitOfWork(ITwoPhaseUnitOfWork twoPhaseUnitOfWork)
 {
     Parent = twoPhaseUnitOfWork ?? throw new ArgumentNullException(nameof(twoPhaseUnitOfWork));
 }
 public static IAsyncUnitOfWork ToUnitOfWork(this ITwoPhaseUnitOfWork twoPhaseUnitOfWork) => new TwoPhaseAsUnitOfWork(twoPhaseUnitOfWork);
 public static async Task SaveChangesAsync(this ITwoPhaseUnitOfWork twoPhaseUnitOfWork, CancellationToken cancellationToken)
 {
     await twoPhaseUnitOfWork.ToUnitOfWork().SaveChangesAsync(cancellationToken).ConfigureAwait(false);
 }
 public SinglePhaseEnlistmentNotification(TwoPhaseTransactionUnitOfWork parent, ITwoPhaseUnitOfWork enlistedEnlistedUnitOfWork)
 {
     _parent                   = parent;
     EnlistedUnitOfWork        = enlistedEnlistedUnitOfWork;
     _cancellationRegistration = _parent.DisposeToken.Register(CompletedCancel);
 }