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; }
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; } }
public void Teardown() { dataMapper.Dispose(); }
public void TearDown() { _builder.Dispose(); _dataMapper.Dispose(); _liftWriter.Dispose(); }