Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
RangeConditionHeaderValue.cs
Go to the documentation of this file.
2
4
6{
7 private readonly DateTimeOffset? _date;
8
10
12
14
16 {
17 _date = date;
18 }
19
21 {
22 if (entityTag == null)
23 {
24 throw new ArgumentNullException("entityTag");
25 }
26 _entityTag = entityTag;
27 }
28
29 public RangeConditionHeaderValue(string entityTag)
30 : this(new EntityTagHeaderValue(entityTag))
31 {
32 }
33
39
40 public override string ToString()
41 {
42 if (_entityTag == null)
43 {
44 return HttpDateParser.DateToString(_date.Value);
45 }
46 return _entityTag.ToString();
47 }
48
49 public override bool Equals([NotNullWhen(true)] object? obj)
50 {
51 if (!(obj is RangeConditionHeaderValue rangeConditionHeaderValue))
52 {
53 return false;
54 }
55 if (_entityTag == null)
56 {
57 if (rangeConditionHeaderValue._date.HasValue)
58 {
59 return _date.Value == rangeConditionHeaderValue._date.Value;
60 }
61 return false;
62 }
63 return _entityTag.Equals(rangeConditionHeaderValue._entityTag);
64 }
65
66 public override int GetHashCode()
67 {
68 if (_entityTag == null)
69 {
70 return _date.Value.GetHashCode();
71 }
72 return _entityTag.GetHashCode();
73 }
74
75 public static RangeConditionHeaderValue Parse(string? input)
76 {
77 int index = 0;
79 }
80
81 public static bool TryParse([NotNullWhen(true)] string? input, [NotNullWhen(true)] out RangeConditionHeaderValue? parsedValue)
82 {
83 int index = 0;
84 parsedValue = null;
85 if (GenericHeaderParser.RangeConditionParser.TryParseValue(input, null, ref index, out var parsedValue2))
86 {
87 parsedValue = (RangeConditionHeaderValue)parsedValue2;
88 return true;
89 }
90 return false;
91 }
92
93 internal static int GetRangeConditionLength(string input, int startIndex, out object parsedValue)
94 {
95 parsedValue = null;
96 if (string.IsNullOrEmpty(input) || startIndex + 1 >= input.Length)
97 {
98 return 0;
99 }
100 int num = startIndex;
102 EntityTagHeaderValue parsedValue2 = null;
103 char c = input[num];
104 char c2 = input[num + 1];
105 if (c == '"' || ((c == 'w' || c == 'W') && c2 == '/'))
106 {
107 int entityTagLength = EntityTagHeaderValue.GetEntityTagLength(input, num, out parsedValue2);
108 if (entityTagLength == 0)
109 {
110 return 0;
111 }
112 num += entityTagLength;
113 if (num != input.Length)
114 {
115 return 0;
116 }
117 }
118 else
119 {
120 if (!HttpDateParser.TryParse(input.AsSpan(num), out result))
121 {
122 return 0;
123 }
124 num = input.Length;
125 }
126 if (parsedValue2 == null)
127 {
128 parsedValue = new RangeConditionHeaderValue(result);
129 }
130 else
131 {
132 parsedValue = new RangeConditionHeaderValue(parsedValue2);
133 }
134 return num - startIndex;
135 }
136
138 {
139 return new RangeConditionHeaderValue(this);
140 }
141}
static string DateToString(DateTimeOffset dateTime)
static bool TryParse(ReadOnlySpan< char > input, out DateTimeOffset result)
static int GetEntityTagLength(string input, int startIndex, out EntityTagHeaderValue parsedValue)
override bool Equals([NotNullWhen(true)] object? obj)
static readonly GenericHeaderParser RangeConditionParser
static bool TryParse([NotNullWhen(true)] string? input, [NotNullWhen(true)] out RangeConditionHeaderValue? parsedValue)
override bool Equals([NotNullWhen(true)] object? obj)
static RangeConditionHeaderValue Parse(string? input)
static int GetRangeConditionLength(string input, int startIndex, out object parsedValue)
override int GetHashCode()
static readonly DateTimeOffset MinValue