Example #1
0
        public LiftDataMapper(string liftFilePath, ProgressState progressState, ILiftReaderWriterProvider <T> ioProvider)
        {
            //set to true so that an exception in the constructor does not cause the destructor to throw
            _disposed = true;
            Guard.AgainstNull(progressState, "progressState");

            _backend       = new MemoryDataMapper <T>();
            _liftFilePath  = liftFilePath;
            _progressState = progressState;
            _ioProvider    = ioProvider;

            try
            {
                CreateEmptyLiftFileIfNeeded(liftFilePath);
                MigrateLiftIfNeeded(progressState);
                LoadAllLexEntries();
            }
            catch (Exception error)
            {
                // Dispose anything that we've created already.
                _backend.Dispose();
                throw;
            }
            //Now that the constructor has not thrown we can set this back to false
            _disposed = false;
        }
Example #2
0
        protected virtual void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                if (disposing)
                {
                    // dispose-only, i.e. non-finalizable logic
                    _backend.Dispose();
                }

                // shared (dispose and finalizable) cleanup logic
                _disposed = true;
            }
        }
Example #3
0
 public void Teardown()
 {
     dataMapper.Dispose();
 }
Example #4
0
 public void TearDown()
 {
     _builder.Dispose();
     _dataMapper.Dispose();
     _liftWriter.Dispose();
 }