Castle.ActiveRecord.TransactionScope.PerformDisposal C# (CSharp) Метод

PerformDisposal() защищенный Метод

Dispose of this scope
protected PerformDisposal ( ICollection sessions ) : void
sessions ICollection The sessions.
Результат void
		protected override void PerformDisposal(ICollection<ISession> sessions)
		{
			if (!setForCommit && !rollbackOnly) // Neither VoteCommit or VoteRollback were called
			{
				if (onDisposeBehavior == OnDispose.Rollback)
				{
					VoteRollBack();
				}
			}
			
			if (mode == TransactionMode.Inherits && parentTransactionScope != null)
			{
				// In this case it's not up to this instance to perform the clean up
				return;
			}

			Exception transactionError = null;

			foreach(ITransaction transaction in transactions.Values)
			{
				try
				{
					if (rollbackOnly)
					{
						transaction.Rollback();
					}
					else
					{
						transaction.Commit();
					}
				}
				catch(Exception ex)
				{
					transactionError = ex;

					transaction.Dispose();
				}
			}

			if (parentSimpleScope == null)
			{
				// No flush necessary, but we should close the session

				PerformDisposal(sessions, false, true);
			}
			else
			{
				if (rollbackOnly)
				{
					// Cancel all pending changes 
					// (not sure whether this is a good idea, it should be scoped

					foreach(ISession session in parentSimpleScope.GetSessions())
					{
						session.Clear();
					}
				}
			}

			RaiseOnCompleted();

			if (transactionError != null)
			{
				throw transactionError;
			}
		}