Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
RangeItemHeaderValue.cs
Go to the documentation of this file.
5
7
9{
10 private readonly long? _from;
11
12 private readonly long? _to;
13
14 public long? From => _from;
15
16 public long? To => _to;
17
18 public RangeItemHeaderValue(long? from, long? to)
19 {
20 if (!from.HasValue && !to.HasValue)
21 {
23 }
24 if (from.HasValue && from.Value < 0)
25 {
26 throw new ArgumentOutOfRangeException("from");
27 }
28 if (to.HasValue && to.Value < 0)
29 {
30 throw new ArgumentOutOfRangeException("to");
31 }
32 if (from.HasValue && to.HasValue && from.Value > to.Value)
33 {
34 throw new ArgumentOutOfRangeException("from");
35 }
36 _from = from;
37 _to = to;
38 }
39
41 {
42 _from = source._from;
43 _to = source._to;
44 }
45
83
84 public override bool Equals([NotNullWhen(true)] object? obj)
85 {
87 {
88 return false;
89 }
90 if (_from == rangeItemHeaderValue._from)
91 {
92 return _to == rangeItemHeaderValue._to;
93 }
94 return false;
95 }
96
97 public override int GetHashCode()
98 {
99 if (!_from.HasValue)
100 {
101 return _to.GetHashCode();
102 }
103 if (!_to.HasValue)
104 {
105 return _from.GetHashCode();
106 }
107 return _from.GetHashCode() ^ _to.GetHashCode();
108 }
109
141
143 {
144 parsedValue = null;
145 if (string.IsNullOrEmpty(input) || startIndex >= input.Length)
146 {
147 return 0;
148 }
149 int num = startIndex;
150 int offset = num;
152 if (numberLength > 19)
153 {
154 return 0;
155 }
156 num += numberLength;
158 if (num == input.Length || input[num] != '-')
159 {
160 return 0;
161 }
162 num++;
164 int offset2 = num;
165 int num2 = 0;
166 if (num < input.Length)
167 {
169 if (num2 > 19)
170 {
171 return 0;
172 }
173 num += num2;
175 }
176 if (numberLength == 0 && num2 == 0)
177 {
178 return 0;
179 }
180 long result = 0L;
182 {
183 return 0;
184 }
185 long result2 = 0L;
187 {
188 return 0;
189 }
190 if (numberLength > 0 && num2 > 0 && result > result2)
191 {
192 return 0;
193 }
194 parsedValue = new RangeItemHeaderValue((numberLength == 0) ? null : new long?(result), (num2 == 0) ? null : new long?(result2));
195 return num - startIndex;
196 }
197
199 {
200 return new RangeItemHeaderValue(this);
201 }
202}
void Add(TKey key, TValue value)
static CultureInfo InvariantCulture
static bool TryParseInt64(string value, int offset, int length, out long result)
static int GetNextNonEmptyOrWhitespaceIndex(string input, int startIndex, bool skipEmptyValues, out bool separatorFound)
override bool Equals([NotNullWhen(true)] object? obj)
static int GetRangeItemLength(string input, int startIndex, out RangeItemHeaderValue parsedValue)
static int GetRangeItemListLength(string input, int startIndex, ICollection< RangeItemHeaderValue > rangeCollection)
static int GetWhitespaceLength(string input, int startIndex)
static int GetNumberLength(string input, int startIndex, bool allowDecimal)
static string net_http_headers_invalid_range
Definition SR.cs:34
Definition SR.cs:7