/// <summary> /// Enlists a <see cref="UnitOfWorkScope"/> instance with the transaction manager, /// with the specified transaction mode. /// </summary> /// <param name="scope">The <see cref="IUnitOfWorkScope"/> to register.</param> /// <param name="mode">A <see cref="TransactionMode"/> enum specifying the transaciton /// mode of the unit of work.</param> public void EnlistScope(IUnitOfWorkScope scope, TransactionMode mode) { _logger.Info(x => x("Enlisting scope {0} with transaction manager {1} with transaction mode {2}", scope.ScopeId, _transactionManagerId, mode)); var uowFactory = _scopeFactory; //Container.Resolve<IUnitOfWorkFactory>(); if (_transactions.Count == 0 || mode == TransactionMode.New || mode == TransactionMode.Supress) { _logger.Debug(x => x("Enlisting scope {0} with mode {1} requires a new TransactionScope to be created.", scope.ScopeId, mode)); var txScope = TransactionScopeHelper.CreateScope(_isolationLevel, mode); var unitOfWork = uowFactory.Create(); Guard.Against <ArgumentException>(!(unitOfWork is IExUnitOfWork), "Ошибка создания UnitOfWork: тек. объект не реализует IExUnitOfWork"); var transaction = new UnityUnitOfWorkTransaction((IExUnitOfWork)unitOfWork, txScope, _subject); transaction.TransactionDisposing += OnTransactionDisposing; transaction.EnlistScope(scope); _transactions.AddFirst(transaction); return; } CurrentTransaction.EnlistScope(scope); }