protected virtual void Dispose(bool disposing) { if (_Disposed) { return; } if (disposing) { _Random?.Dispose(); _Random = null; } _Disposed = true; }
protected virtual void Dispose(bool disposing) { if (_Disposed) { return; } var exceptions = new List <Exception>(); if (disposing) { _Random.Dispose(); _Random = null; while (_Paths.TryDequeue(out var path)) { try { if (File.Exists(path)) { File.Delete(path); } } catch (Exception exception) { exceptions.Add(exception); } } } _Disposed = true; if (exceptions.Count == 1) { throw exceptions[0]; } else if (exceptions.Count > 1) { throw new AggregateException(exceptions); } }
public TemporaryFileContext(string prefix, string extension) { _Random = new HardRandom(); _Prefix = prefix; _Extension = extension; }