Пример #1
0
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (!Nested)
            {
                if (!_completed)
                {
                    try
                    {
                        if (_readOnly)
                        {
                            ScopeData.Commit();
                        }
                        else
                        {
                            ScopeData.Rollback();
                        }
                    }
                    catch (Exception e)
                    {
                        _exceptionHandler?.HandleException(e);
                    }
                }

                _completed = true;
                ScopeData.Dispose();
            }
        }
        public void Dispose()
        {
            if (_disposed)
            {
                return;
            }

            if (!_completed)
            {
                try
                {
                    if (_readOnly)
                    {
                        Commit();
                    }
                    else
                    {
                        Rollback();
                    }
                }
                catch (Exception e)
                {
                    _exceptionHandler?.HandleException(e);
                }
            }

            foreach (var conn in InitializedConnections.Values)
            {
                try
                {
                    conn.Dispose();
                }
                catch (Exception e)
                {
                    _exceptionHandler?.HandleException(e);
                }
            }

            InitializedConnections.Clear();
            _disposed = true;
        }