/// <summary>Disposes of this class and closes the database file.</summary> public void Dispose() { _stream?.Dispose(); _reader?.Dispose(); _stream = null; _reader = null; }
/// <summary> /// Constructor. Ensures that the specified database file exists. The database file remains open until this /// instance is disposed of. Creating instances of this class is cheap, but reusing an instance when performing /// large numbers of lookups will improve performance.</summary> /// <param name="dbFileName"> /// The name of the HIBP database file. The format of this file is specific to PwnedLib; use PwnedGen to generate /// one. See documentation on the project website.</param> public PwnedChecker(string dbFileName) { DbFileName = dbFileName; if (!File.Exists(dbFileName)) { throw new ArgumentException($"The specified file does not exist: \"{dbFileName}\"", "dbFileName"); } _stream = File.Open(DbFileName, FileMode.Open, FileAccess.Read, FileShare.Read); _reader = new BinaryReader2(_stream); }