Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
EntityTagHeaderValue.cs
Go to the documentation of this file.
1
using
System.Diagnostics.CodeAnalysis
;
2
3
namespace
System.Net.Http.Headers
;
4
5
public
class
EntityTagHeaderValue
:
ICloneable
6
{
7
private
readonly
string
_tag
;
8
9
private
readonly
bool
_isWeak
;
10
11
public
string
Tag
=>
_tag
;
12
13
public
bool
IsWeak
=>
_isWeak
;
14
15
public
static
EntityTagHeaderValue
Any
{
get
; } =
new
EntityTagHeaderValue
();
16
17
18
private
EntityTagHeaderValue
()
19
{
20
_tag
=
"*"
;
21
}
22
23
public
EntityTagHeaderValue
(
string
tag)
24
: this(tag, isWeak: false)
25
{
26
}
27
28
public
EntityTagHeaderValue
(
string
tag,
bool
isWeak)
29
{
30
if
(
string
.IsNullOrEmpty(tag))
31
{
32
throw
new
ArgumentException
(
System
.
SR
.
net_http_argument_empty_string
,
"tag"
);
33
}
34
int
length
= 0;
35
if
(
HttpRuleParser
.
GetQuotedStringLength
(tag, 0, out
length
) != 0 ||
length
!= tag.Length)
36
{
37
throw
new
FormatException
(
System
.
SR
.
net_http_headers_invalid_etag_name
);
38
}
39
_tag
= tag;
40
_isWeak
= isWeak;
41
}
42
43
private
EntityTagHeaderValue
(
EntityTagHeaderValue
source
)
44
{
45
_tag
=
source
._tag;
46
_isWeak
=
source
._isWeak;
47
}
48
49
public
override
string
ToString
()
50
{
51
if
(
_isWeak
)
52
{
53
return
"W/"
+
_tag
;
54
}
55
return
_tag
;
56
}
57
58
public
override
bool
Equals
([NotNullWhen(
true
)]
object
?
obj
)
59
{
60
if
(!(
obj
is
EntityTagHeaderValue
entityTagHeaderValue))
61
{
62
return
false
;
63
}
64
if
(
_isWeak
== entityTagHeaderValue._isWeak)
65
{
66
return
string
.Equals(
_tag
, entityTagHeaderValue._tag,
StringComparison
.Ordinal);
67
}
68
return
false
;
69
}
70
71
public
override
int
GetHashCode
()
72
{
73
return
_tag
.GetHashCode() ^
_isWeak
.GetHashCode();
74
}
75
76
public
static
EntityTagHeaderValue
Parse
(
string
?
input
)
77
{
78
int
index
= 0;
79
return
(
EntityTagHeaderValue
)
GenericHeaderParser
.
SingleValueEntityTagParser
.ParseValue(
input
,
null
, ref
index
);
80
}
81
82
public
static
bool
TryParse
([NotNullWhen(
true
)]
string
?
input
, [NotNullWhen(
true
)] out
EntityTagHeaderValue
? parsedValue)
83
{
84
int
index
= 0;
85
parsedValue =
null
;
86
if
(
GenericHeaderParser
.
SingleValueEntityTagParser
.TryParseValue(
input
,
null
, ref
index
, out var parsedValue2))
87
{
88
parsedValue = (
EntityTagHeaderValue
)parsedValue2;
89
return
true
;
90
}
91
return
false
;
92
}
93
94
internal
static
int
GetEntityTagLength
(
string
input
,
int
startIndex
, out
EntityTagHeaderValue
parsedValue)
95
{
96
parsedValue =
null
;
97
if
(
string
.IsNullOrEmpty(
input
) ||
startIndex
>=
input
.Length)
98
{
99
return
0;
100
}
101
bool
isWeak =
false
;
102
int
num =
startIndex
;
103
char
c =
input
[
startIndex
];
104
if
(c ==
'*'
)
105
{
106
parsedValue =
Any
;
107
num++;
108
}
109
else
110
{
111
if
(c ==
'W'
|| c ==
'w'
)
112
{
113
num++;
114
if
(num + 2 >=
input
.Length ||
input
[num] !=
'/'
)
115
{
116
return
0;
117
}
118
isWeak =
true
;
119
num++;
120
num +=
HttpRuleParser
.
GetWhitespaceLength
(
input
, num);
121
}
122
int
startIndex2 = num;
123
int
length
= 0;
124
if
(
HttpRuleParser
.
GetQuotedStringLength
(
input
, num, out
length
) != 0)
125
{
126
return
0;
127
}
128
parsedValue =
new
EntityTagHeaderValue
();
129
if
(
length
==
input
.Length)
130
{
131
parsedValue =
new
EntityTagHeaderValue
(
input
);
132
}
133
else
134
{
135
parsedValue =
new
EntityTagHeaderValue
(
input
.Substring(startIndex2,
length
), isWeak);
136
}
137
num +=
length
;
138
}
139
num +=
HttpRuleParser
.
GetWhitespaceLength
(
input
, num);
140
return
num -
startIndex
;
141
}
142
143
object
ICloneable
.
Clone
()
144
{
145
if
(
this
!=
Any
)
146
{
147
return
new
EntityTagHeaderValue
(
this
);
148
}
149
return
Any
;
150
}
151
}
System.ArgumentException
Definition
ArgumentException.cs:9
System.FormatException
Definition
FormatException.cs:9
System.Net.Http.Headers.EntityTagHeaderValue.IsWeak
bool IsWeak
Definition
EntityTagHeaderValue.cs:13
System.Net.Http.Headers.EntityTagHeaderValue._isWeak
readonly bool _isWeak
Definition
EntityTagHeaderValue.cs:9
System.Net.Http.Headers.EntityTagHeaderValue.EntityTagHeaderValue
EntityTagHeaderValue(string tag)
Definition
EntityTagHeaderValue.cs:23
System.Net.Http.Headers.EntityTagHeaderValue._tag
readonly string _tag
Definition
EntityTagHeaderValue.cs:7
System.Net.Http.Headers.EntityTagHeaderValue.ToString
override string ToString()
Definition
EntityTagHeaderValue.cs:49
System.Net.Http.Headers.EntityTagHeaderValue.TryParse
static bool TryParse([NotNullWhen(true)] string? input, [NotNullWhen(true)] out EntityTagHeaderValue? parsedValue)
Definition
EntityTagHeaderValue.cs:82
System.Net.Http.Headers.EntityTagHeaderValue.EntityTagHeaderValue
EntityTagHeaderValue()
Definition
EntityTagHeaderValue.cs:18
System.Net.Http.Headers.EntityTagHeaderValue.GetHashCode
override int GetHashCode()
Definition
EntityTagHeaderValue.cs:71
System.Net.Http.Headers.EntityTagHeaderValue.GetEntityTagLength
static int GetEntityTagLength(string input, int startIndex, out EntityTagHeaderValue parsedValue)
Definition
EntityTagHeaderValue.cs:94
System.Net.Http.Headers.EntityTagHeaderValue.EntityTagHeaderValue
EntityTagHeaderValue(EntityTagHeaderValue source)
Definition
EntityTagHeaderValue.cs:43
System.Net.Http.Headers.EntityTagHeaderValue.Tag
string Tag
Definition
EntityTagHeaderValue.cs:11
System.Net.Http.Headers.EntityTagHeaderValue.Parse
static EntityTagHeaderValue Parse(string? input)
Definition
EntityTagHeaderValue.cs:76
System.Net.Http.Headers.EntityTagHeaderValue.Equals
override bool Equals([NotNullWhen(true)] object? obj)
Definition
EntityTagHeaderValue.cs:58
System.Net.Http.Headers.EntityTagHeaderValue.EntityTagHeaderValue
EntityTagHeaderValue(string tag, bool isWeak)
Definition
EntityTagHeaderValue.cs:28
System.Net.Http.Headers.EntityTagHeaderValue.Any
static EntityTagHeaderValue Any
Definition
EntityTagHeaderValue.cs:15
System.Net.Http.Headers.EntityTagHeaderValue
Definition
EntityTagHeaderValue.cs:6
System.Net.Http.Headers.GenericHeaderParser.SingleValueEntityTagParser
static readonly GenericHeaderParser SingleValueEntityTagParser
Definition
GenericHeaderParser.cs:45
System.Net.Http.Headers.GenericHeaderParser
Definition
GenericHeaderParser.cs:6
System.Net.Http.HttpRuleParser.GetQuotedStringLength
static HttpParseResult GetQuotedStringLength(string input, int startIndex, out int length)
Definition
HttpRuleParser.cs:187
System.Net.Http.HttpRuleParser.GetWhitespaceLength
static int GetWhitespaceLength(string input, int startIndex)
Definition
HttpRuleParser.cs:92
System.Net.Http.HttpRuleParser
Definition
HttpRuleParser.cs:6
System.SR.net_http_headers_invalid_etag_name
static string net_http_headers_invalid_etag_name
Definition
SR.cs:32
System.SR.net_http_argument_empty_string
static string net_http_argument_empty_string
Definition
SR.cs:52
System.SR
Definition
SR.cs:7
System.ICloneable.Clone
object Clone()
System.ICloneable
Definition
ICloneable.cs:4
System.Diagnostics.CodeAnalysis
Definition
AllowNullAttribute.cs:1
System.Net.Http.Headers
Definition
AltSvcHeaderParser.cs:4
System.ExceptionArgument.startIndex
@ startIndex
System.ExceptionArgument.length
@ length
System.ExceptionArgument.source
@ source
System.ExceptionArgument.index
@ index
System.ExceptionArgument.input
@ input
System.ExceptionArgument.obj
@ obj
System.StringComparison
StringComparison
Definition
StringComparison.cs:4
System
Definition
BlockingCollection.cs:8
source
System.Net.Http
System.Net.Http.Headers
EntityTagHeaderValue.cs
Generated by
1.10.0