private void LoadFromFileName(string filename) { _fileName = filename; StreamReader reader = null; try { if (PreserveWhitespace) { _preservationProvider = new XmlAttributePreservationProvider(filename); } const int defaultFileStreamBufferSize = 1024; var stream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read, defaultFileStreamBufferSize, FileOptions.SequentialScan); reader = new StreamReader(stream, Encoding.UTF8, true); LoadFromTextReader(reader); } finally { if (_preservationProvider != null) { _preservationProvider.Close(); _preservationProvider = null; } if (reader != null) { reader.Dispose(); } } }
protected virtual void Dispose(bool disposing) { if (_reader != null) { _reader.Dispose(); _reader = null; } if (_preservationProvider != null) { _preservationProvider.Close(); _preservationProvider = null; } }