Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SqlStreamChars.cs
Go to the documentation of this file.
2using System.IO;
4
6
7internal sealed class SqlStreamChars
8{
9 private readonly SqlChars _sqlchars;
10
11 private long _lPosition;
12
13 public long Length
14 {
15 get
16 {
17 CheckIfStreamClosed("get_Length");
18 return _sqlchars.Length;
19 }
20 }
21
22 public long Position
23 {
24 get
25 {
26 CheckIfStreamClosed("get_Position");
27 return _lPosition;
28 }
29 }
30
31 public long Seek(long offset, SeekOrigin origin)
32 {
33 CheckIfStreamClosed("Seek");
34 long num = 0L;
35 switch (origin)
36 {
37 case SeekOrigin.Begin:
38 if (offset < 0 || offset > _sqlchars.Length)
39 {
40 throw ADP.ArgumentOutOfRange("offset");
41 }
43 break;
44 case SeekOrigin.Current:
45 num = _lPosition + offset;
46 if (num < 0 || num > _sqlchars.Length)
47 {
48 throw ADP.ArgumentOutOfRange("offset");
49 }
50 _lPosition = num;
51 break;
52 case SeekOrigin.End:
53 num = _sqlchars.Length + offset;
54 if (num < 0 || num > _sqlchars.Length)
55 {
56 throw ADP.ArgumentOutOfRange("offset");
57 }
58 _lPosition = num;
59 break;
60 default:
61 throw ADP.ArgumentOutOfRange("offset");
62 }
63 return _lPosition;
64 }
65
66 public int Read(char[] buffer, int offset, int count)
67 {
68 CheckIfStreamClosed("Read");
69 if (buffer == null)
70 {
71 throw new ArgumentNullException("buffer");
72 }
73 if (offset < 0 || offset > buffer.Length)
74 {
75 throw new ArgumentOutOfRangeException("offset");
76 }
77 if (count < 0 || count > buffer.Length - offset)
78 {
79 throw new ArgumentOutOfRangeException("count");
80 }
81 int num = (int)_sqlchars.Read(_lPosition, buffer, offset, count);
82 _lPosition += num;
83 return num;
84 }
85
86 public void Write(char[] buffer, int offset, int count)
87 {
88 CheckIfStreamClosed("Write");
89 if (buffer == null)
90 {
91 throw new ArgumentNullException("buffer");
92 }
93 if (offset < 0 || offset > buffer.Length)
94 {
95 throw new ArgumentOutOfRangeException("offset");
96 }
97 if (count < 0 || count > buffer.Length - offset)
98 {
99 throw new ArgumentOutOfRangeException("count");
100 }
102 _lPosition += count;
103 }
104
105 public void SetLength(long value)
106 {
107 CheckIfStreamClosed("SetLength");
109 if (_lPosition > value)
110 {
112 }
113 }
114
115 private bool FClosed()
116 {
117 return _sqlchars == null;
118 }
119
120 private void CheckIfStreamClosed([CallerMemberName] string methodname = "")
121 {
122 if (FClosed())
123 {
124 throw ADP.StreamClosed(methodname);
125 }
126 }
127}
static ArgumentOutOfRangeException ArgumentOutOfRange(string parameterName)
Definition ADP.cs:713
static Exception StreamClosed([CallerMemberName] string method="")
Definition ADP.cs:875
void Write(long offset, char[] buffer, int offsetInBuffer, int count)
Definition SqlChars.cs:227
long Read(long offset, char[] buffer, int offsetInBuffer, int count)
Definition SqlChars.cs:182
void SetLength(long value)
Definition SqlChars.cs:156
long Seek(long offset, SeekOrigin origin)
void Write(char[] buffer, int offset, int count)
int Read(char[] buffer, int offset, int count)
void CheckIfStreamClosed([CallerMemberName] string methodname="")