diff --git a/EightBit/Bus.cs b/EightBit/Bus.cs index 1f7aa06..3b029e2 100644 --- a/EightBit/Bus.cs +++ b/EightBit/Bus.cs @@ -122,7 +122,7 @@ namespace EightBit protected void LoadHexFile(string path) { - using var file = new IntelHexFile(path); + var file = new IntelHexFile(path); foreach (var (address, content) in file.Parse()) { var mapped = this.Mapping(address); diff --git a/EightBit/IntelHexFile.cs b/EightBit/IntelHexFile.cs index 659a34a..787bb31 100644 --- a/EightBit/IntelHexFile.cs +++ b/EightBit/IntelHexFile.cs @@ -8,24 +8,18 @@ namespace EightBit using System.Collections.Generic; using System.IO; - public class IntelHexFile(string path) : IDisposable + public class IntelHexFile(string path) { - private readonly StreamReader reader = File.OpenText(path); + private readonly string _path = path; private bool eof; - private bool disposed = false; - - public void Dispose() - { - this.Dispose(true); - GC.SuppressFinalize(this); - } public IEnumerable> Parse() { this.eof = false; - while (!this.reader.EndOfStream && !this.eof) + using var reader = File.OpenText(this._path); + while (!reader.EndOfStream && !this.eof) { - var line = this.reader.ReadLine() ?? throw new InvalidOperationException("Early EOF detected"); + var line = reader.ReadLine() ?? throw new InvalidOperationException("Early EOF detected"); var parsed = this.Parse(line); if (parsed != null) { @@ -39,19 +33,6 @@ namespace EightBit } } - protected virtual void Dispose(bool disposing) - { - if (!this.disposed) - { - if (disposing) - { - this.reader.Dispose(); - } - - this.disposed = true; - } - } - private static byte[] ParseDataRecord(string line, byte count) { ArgumentNullException.ThrowIfNullOrEmpty(line);