public void RegisterSynchronization(ITransactionCompletionSynchronization synchronization) { if (synchronization == null) { throw new ArgumentNullException(nameof(synchronization)); } HasRegisteredSynchronization = true; }
public void RegisterSynchronization(ITransactionCompletionSynchronization sync) { if (sync == null) { throw new ArgumentNullException("sync"); } if (synchronizations == null) { synchronizations = new List <ITransactionCompletionSynchronization>(); } synchronizations.Add(sync); }
public void RegisterSynchronization(ITransactionCompletionSynchronization synchronization) { if (synchronization == null) { throw new ArgumentNullException(nameof(synchronization)); } // It is tempting to use the session ActionQueue instead, but stateless sessions do not have one. if (_completionSynchronizations == null) { _completionSynchronizations = new List <ITransactionCompletionSynchronization>(); } _completionSynchronizations.Add(synchronization); }
/// <summary> /// Register an user synchronization callback for this transaction. /// </summary> /// <param name="transaction">The transaction.</param> /// <param name="synchronization">The <see cref="ISynchronization"/> callback to register.</param> public static void RegisterSynchronization( this ITransaction transaction, ITransactionCompletionSynchronization synchronization) { if (transaction is AdoTransaction adoTransaction) { adoTransaction.RegisterSynchronization(synchronization); return; } // Use reflection for supporting custom transaction factories and transaction implementations. var registerMethod = transaction.GetType().GetMethod( nameof(AdoTransaction.RegisterSynchronization), new[] { typeof(ITransactionCompletionSynchronization) }); if (registerMethod == null) { throw new NotSupportedException( $"{transaction.GetType()} does not support {nameof(ITransactionCompletionSynchronization)}"); } registerMethod.Invoke(transaction, new object[] { synchronization }); }