Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ReadLinesIterator.cs
Go to the documentation of this file.
1using System.Text;
2
3namespace System.IO;
4
5internal sealed class ReadLinesIterator : Iterator<string>
6{
7 private readonly string _path;
8
9 private readonly Encoding _encoding;
10
12
13 private ReadLinesIterator(string path, Encoding encoding, StreamReader reader)
14 {
15 _path = path;
16 _encoding = encoding;
17 _reader = reader;
18 }
19
20 public override bool MoveNext()
21 {
22 if (_reader != null)
23 {
25 if (current != null)
26 {
27 return true;
28 }
29 Dispose();
30 }
31 return false;
32 }
33
34 protected override Iterator<string> Clone()
35 {
37 }
38
39 protected override void Dispose(bool disposing)
40 {
41 try
42 {
43 if (disposing && _reader != null)
44 {
46 }
47 }
48 finally
49 {
50 _reader = null;
51 base.Dispose(disposing);
52 }
53 }
54
55 internal static ReadLinesIterator CreateIterator(string path, Encoding encoding)
56 {
57 return CreateIterator(path, encoding, null);
58 }
59
60 private static ReadLinesIterator CreateIterator(string path, Encoding encoding, StreamReader reader)
61 {
62 return new ReadLinesIterator(path, encoding, reader ?? new StreamReader(path, encoding));
63 }
64}
static ReadLinesIterator CreateIterator(string path, Encoding encoding, StreamReader reader)
override Iterator< string > Clone()
override void Dispose(bool disposing)
static ReadLinesIterator CreateIterator(string path, Encoding encoding)
ReadLinesIterator(string path, Encoding encoding, StreamReader reader)
override void Dispose(bool disposing)
override? string ReadLine()