public void Open(string path, IValue encoding = null, string lineDelimiter = "\n", string eolDelimiter = null, bool?monopoly = null) { Close(); TextReader imReader = null; var shareMode = (monopoly ?? true) ? FileShare.None : FileShare.ReadWrite; if (encoding == null) { imReader = OpenReader(path, shareMode); } if (encoding != null && encoding.BaseType == ValueTypeEnum.NULL) { imReader = OpenReader(path, shareMode); } if (imReader == null) { var enc = TextEncoding.GetEncoding(encoding); imReader = OpenReader(path, shareMode, enc); } _lineDelimiter = lineDelimiter ?? "\n"; if (eolDelimiter != null) { _reader = new CustomLineFeedStreamReader(imReader, eolDelimiter, AnalyzeDefaultLineFeed); } else { _reader = new CustomLineFeedStreamReader(imReader, "\r\n", AnalyzeDefaultLineFeed); } }
public void Dispose() { if (_reader != null) { _reader.Dispose(); _reader = null; } }