Example #1
0
        public void Dispose()
        {
            if (_disposed)
            {
                return;
            }

            TransactionalFlush();

            if (_transaction != null)
            {
                _transaction.Dispose();
                _transaction = null;
            }
            //if (_session != null)
            //{
            //    _session.Dispose();
            //}
            _session = null;

            _factory.DisposeUnitOfWork();
            UnitOfWorkScope.DisposeUnitOfWork();

            _disposed = true;
        }
 public void Can_Dispose_UnitOfWorkImplementor()
 {
     using (_mocks.Record())
     {
         Expect.Call(() => _factory.DisposeUnitOfWork(null)).IgnoreArguments();
         Expect.Call(_session.Dispose);
     }
     using (_mocks.Playback())
     {
         _uow = new UnitOfWorkImplementor(_factory, _session);
         _uow.Dispose();
     }
 }
        /// <summary>
        /// Release resources
        /// </summary>
        /// <param name="disposing">release managed resources.</param>
        protected virtual void Dispose(bool disposing)
        {
            if (IsDisposed)
            {
                return;
            }

            if (disposing)
            {
                if (IsDebugEnabled)
                {
                    log.Debug("Disposing NHUnitOfWorkAdapter instance...");
                }

                Interlocked.Decrement(ref _usageCount);

                if (IsDebugEnabled)
                {
                    log.Debug("Usage count of NHUnitOfWork : " + _usageCount);
                }

                if (_usageCount != 0)
                {
                    if (IsDebugEnabled)
                    {
                        log.Debug("NHUnitOfWorkAdapter 사용 수가 0이 아니므로 Dispose 하지 않습니다.");
                    }

                    return;
                }

                if (_factory != null)
                {
                    With.TryAction(() => _factory.DisposeUnitOfWork(this));
                }

                if (_session != null)
                {
                    With.TryAction(() => _session.Dispose());
                }

                if (IsDebugEnabled)
                {
                    log.Debug("Disposed NHUnitOfWorkAdapter instance!!!");
                }
            }

            IsDisposed = true;
        }
 public void Dispose()
 {
     _factory.DisposeUnitOfWork(this);
     _session.Dispose();
 }