Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
HttpHeaderValueCollection.cs
Go to the documentation of this file.
1
using
System.Collections
;
2
using
System.Collections.Generic
;
3
4
namespace
System.Net.Http.Headers
;
5
6
public
sealed
class
HttpHeaderValueCollection
<T> :
ICollection
<T>,
IEnumerable
<T>,
IEnumerable
where
T :
class
7
{
8
private
readonly
HeaderDescriptor
_descriptor
;
9
10
private
readonly
HttpHeaders
_store
;
11
12
private
readonly T
_specialValue
;
13
14
private
readonly
Action<HttpHeaderValueCollection<T>
, T>
_validator
;
15
16
public
int
Count
=>
GetCount
();
17
18
public
bool
IsReadOnly
=>
false
;
19
20
internal
bool
IsSpecialValueSet
21
{
22
get
23
{
24
if
(
_specialValue
==
null
)
25
{
26
return
false
;
27
}
28
return
_store
.
ContainsParsedValue
(
_descriptor
,
_specialValue
);
29
}
30
}
31
32
internal
HttpHeaderValueCollection
(
HeaderDescriptor
descriptor,
HttpHeaders
store
)
33
:
this
(descriptor,
store
, (T)
null
, (Action<
HttpHeaderValueCollection
<T>, T>)
null
)
34
{
35
}
36
37
internal
HttpHeaderValueCollection
(
HeaderDescriptor
descriptor,
HttpHeaders
store
, Action<
HttpHeaderValueCollection<T>
, T> validator)
38
:
this
(descriptor,
store
, (T)
null
, validator)
39
{
40
}
41
42
internal
HttpHeaderValueCollection
(
HeaderDescriptor
descriptor,
HttpHeaders
store
, T
specialValue
)
43
:
this
(descriptor,
store
,
specialValue
, (Action<
HttpHeaderValueCollection
<T>, T>)
null
)
44
{
45
}
46
47
internal
HttpHeaderValueCollection
(
HeaderDescriptor
descriptor,
HttpHeaders
store
, T
specialValue
, Action<
HttpHeaderValueCollection<T>
, T> validator)
48
{
49
_store
=
store
;
50
_descriptor
= descriptor;
51
_specialValue
=
specialValue
;
52
_validator
= validator;
53
}
54
55
public
void
Add
(T
item
)
56
{
57
CheckValue
(
item
);
58
_store
.
AddParsedValue
(
_descriptor
,
item
);
59
}
60
61
public
void
ParseAdd
(
string
?
input
)
62
{
63
_store
.
Add
(
_descriptor
,
input
);
64
}
65
66
public
bool
TryParseAdd
(
string
?
input
)
67
{
68
return
_store
.
TryParseAndAddValue
(
_descriptor
,
input
);
69
}
70
71
public
void
Clear
()
72
{
73
_store
.
Remove
(
_descriptor
);
74
}
75
76
public
bool
Contains
(T
item
)
77
{
78
CheckValue
(
item
);
79
return
_store
.
ContainsParsedValue
(
_descriptor
,
item
);
80
}
81
82
public
void
CopyTo
(T[]
array
,
int
arrayIndex
)
83
{
84
if
(
array
==
null
)
85
{
86
throw
new
ArgumentNullException
(
"array"
);
87
}
88
if
(
arrayIndex < 0 || arrayIndex >
array
.Length)
89
{
90
throw
new
ArgumentOutOfRangeException
(
"arrayIndex"
);
91
}
92
object
parsedValues
=
_store
.
GetParsedValues
(
_descriptor
);
93
if
(
parsedValues
==
null
)
94
{
95
return
;
96
}
97
if
(!(
parsedValues
is
List<object>
list
))
98
{
99
if
(
arrayIndex
==
array
.Length)
100
{
101
throw
new
ArgumentException
(
System
.
SR
.
net_http_copyto_array_too_small
);
102
}
103
array
[
arrayIndex
] = (
T
)
parsedValues
;
104
}
105
else
106
{
107
list
.
CopyTo
(
array
,
arrayIndex
);
108
}
109
}
110
111
public
bool
Remove
(T
item
)
112
{
113
CheckValue
(
item
);
114
return
_store
.
RemoveParsedValue
(
_descriptor
,
item
);
115
}
116
117
public
IEnumerator<T>
GetEnumerator
()
118
{
119
object
parsedValues
=
_store
.
GetParsedValues
(
_descriptor
);
120
if
(
parsedValues
!=
null
)
121
{
122
return
Iterate
(
parsedValues
);
123
}
124
return
((
IEnumerable<T>
)
Array
.Empty<T>()).GetEnumerator();
125
static
IEnumerator<T>
Iterate
(
object
storeValue
)
126
{
127
if
(
storeValue
is
List<object>
list
)
128
{
129
foreach
(
object
item
in
list
)
130
{
131
yield
return
(T)
item
;
132
}
133
}
134
else
135
{
136
yield
return
(T)
storeValue
;
137
}
138
}
139
}
140
141
IEnumerator
IEnumerable
.
GetEnumerator
()
142
{
143
return
GetEnumerator
();
144
}
145
146
public
override
string
ToString
()
147
{
148
return
_store
.
GetHeaderString
(
_descriptor
);
149
}
150
151
internal
void
SetSpecialValue
()
152
{
153
if
(!
_store
.
ContainsParsedValue
(
_descriptor
,
_specialValue
))
154
{
155
_store
.
AddParsedValue
(
_descriptor
,
_specialValue
);
156
}
157
}
158
159
internal
void
RemoveSpecialValue
()
160
{
161
_store
.
RemoveParsedValue
(
_descriptor
,
_specialValue
);
162
}
163
164
private
void
CheckValue
(T
item
)
165
{
166
if
(
item
==
null
)
167
{
168
throw
new
ArgumentNullException
(
"item"
);
169
}
170
if
(
_validator
!=
null
)
171
{
172
_validator
(
this
,
item
);
173
}
174
}
175
176
private
int
GetCount
()
177
{
178
object
parsedValues
=
_store
.
GetParsedValues
(
_descriptor
);
179
if
(
parsedValues
==
null
)
180
{
181
return
0;
182
}
183
if
(!(
parsedValues
is
List<object>
list
))
184
{
185
return
1;
186
}
187
return
list
.Count;
188
}
189
}
System.ArgumentException
Definition
ArgumentException.cs:9
System.ArgumentNullException
Definition
ArgumentNullException.cs:10
System.ArgumentOutOfRangeException
Definition
ArgumentOutOfRangeException.cs:9
System.Array
Definition
Array.cs:16
System.Collections.Generic.Dictionary.CopyTo
void CopyTo(KeyValuePair< TKey, TValue >[] array, int index)
Definition
Dictionary.cs:959
System.Collections.Generic.Dictionary
Definition
Dictionary.cs:14
System.Net.Http.Headers.HttpHeaderValueCollection.IsReadOnly
bool IsReadOnly
Definition
HttpHeaderValueCollection.cs:18
System.Net.Http.Headers.HttpHeaderValueCollection.Contains
bool Contains(T item)
Definition
HttpHeaderValueCollection.cs:76
System.Net.Http.Headers.HttpHeaderValueCollection.HttpHeaderValueCollection
HttpHeaderValueCollection(HeaderDescriptor descriptor, HttpHeaders store, T specialValue)
Definition
HttpHeaderValueCollection.cs:42
System.Net.Http.Headers.HttpHeaderValueCollection.SetSpecialValue
void SetSpecialValue()
Definition
HttpHeaderValueCollection.cs:151
System.Net.Http.Headers.HttpHeaderValueCollection._specialValue
readonly T _specialValue
Definition
HttpHeaderValueCollection.cs:12
System.Net.Http.Headers.HttpHeaderValueCollection.TryParseAdd
bool TryParseAdd(string? input)
Definition
HttpHeaderValueCollection.cs:66
System.Net.Http.Headers.HttpHeaderValueCollection.HttpHeaderValueCollection
HttpHeaderValueCollection(HeaderDescriptor descriptor, HttpHeaders store, Action< HttpHeaderValueCollection< T >, T > validator)
Definition
HttpHeaderValueCollection.cs:37
System.Net.Http.Headers.HttpHeaderValueCollection.HttpHeaderValueCollection
HttpHeaderValueCollection(HeaderDescriptor descriptor, HttpHeaders store)
Definition
HttpHeaderValueCollection.cs:32
System.Net.Http.Headers.HttpHeaderValueCollection.Count
int Count
Definition
HttpHeaderValueCollection.cs:16
System.Net.Http.Headers.HttpHeaderValueCollection.Clear
void Clear()
Definition
HttpHeaderValueCollection.cs:71
System.Net.Http.Headers.HttpHeaderValueCollection.HttpHeaderValueCollection
HttpHeaderValueCollection(HeaderDescriptor descriptor, HttpHeaders store, T specialValue, Action< HttpHeaderValueCollection< T >, T > validator)
Definition
HttpHeaderValueCollection.cs:47
System.Net.Http.Headers.HttpHeaderValueCollection.ParseAdd
void ParseAdd(string? input)
Definition
HttpHeaderValueCollection.cs:61
System.Net.Http.Headers.HttpHeaderValueCollection._store
readonly HttpHeaders _store
Definition
HttpHeaderValueCollection.cs:10
System.Net.Http.Headers.HttpHeaderValueCollection.Add
void Add(T item)
Definition
HttpHeaderValueCollection.cs:55
System.Net.Http.Headers.HttpHeaderValueCollection.GetCount
int GetCount()
Definition
HttpHeaderValueCollection.cs:176
System.Net.Http.Headers.HttpHeaderValueCollection.CopyTo
void CopyTo(T[] array, int arrayIndex)
Definition
HttpHeaderValueCollection.cs:82
System.Net.Http.Headers.HttpHeaderValueCollection.GetEnumerator
IEnumerator< T > GetEnumerator()
Definition
HttpHeaderValueCollection.cs:117
System.Net.Http.Headers.HttpHeaderValueCollection.Remove
bool Remove(T item)
Definition
HttpHeaderValueCollection.cs:111
System.Net.Http.Headers.HttpHeaderValueCollection.ToString
override string ToString()
Definition
HttpHeaderValueCollection.cs:146
System.Net.Http.Headers.HttpHeaderValueCollection.RemoveSpecialValue
void RemoveSpecialValue()
Definition
HttpHeaderValueCollection.cs:159
System.Net.Http.Headers.HttpHeaderValueCollection.IsSpecialValueSet
bool IsSpecialValueSet
Definition
HttpHeaderValueCollection.cs:21
System.Net.Http.Headers.HttpHeaderValueCollection._validator
readonly Action< HttpHeaderValueCollection< T >, T > _validator
Definition
HttpHeaderValueCollection.cs:14
System.Net.Http.Headers.HttpHeaderValueCollection._descriptor
readonly HeaderDescriptor _descriptor
Definition
HttpHeaderValueCollection.cs:8
System.Net.Http.Headers.HttpHeaderValueCollection.CheckValue
void CheckValue(T item)
Definition
HttpHeaderValueCollection.cs:164
System.Net.Http.Headers.HttpHeaderValueCollection
Definition
HttpHeaderValueCollection.cs:7
System.Net.Http.Headers.HttpHeaders.TryParseAndAddValue
bool TryParseAndAddValue(HeaderDescriptor descriptor, string value)
Definition
HttpHeaders.cs:681
System.Net.Http.Headers.HttpHeaders.GetHeaderString
string GetHeaderString(HeaderDescriptor descriptor)
Definition
HttpHeaders.cs:282
System.Net.Http.Headers.HttpHeaders.RemoveParsedValue
bool RemoveParsedValue(HeaderDescriptor descriptor, object value)
Definition
HttpHeaders.cs:380
System.Net.Http.Headers.HttpHeaders.Remove
bool Remove(string name)
Definition
HttpHeaders.cs:366
System.Net.Http.Headers.HttpHeaders.ContainsParsedValue
bool ContainsParsedValue(HeaderDescriptor descriptor, object value)
Definition
HttpHeaders.cs:426
System.Net.Http.Headers.HttpHeaders.AddParsedValue
void AddParsedValue(HeaderDescriptor descriptor, object value)
Definition
HttpHeaders.cs:339
System.Net.Http.Headers.HttpHeaders.Add
void Add(string name, string? value)
Definition
HttpHeaders.cs:71
System.Net.Http.Headers.HttpHeaders.GetParsedValues
object GetParsedValues(HeaderDescriptor descriptor)
Definition
HttpHeaders.cs:779
System.Net.Http.Headers.HttpHeaders
Definition
HttpHeaders.cs:11
System.SR.net_http_copyto_array_too_small
static string net_http_copyto_array_too_small
Definition
SR.cs:18
System.SR
Definition
SR.cs:7
System.Collections.Generic.ICollection
Definition
ICollection.cs:4
System.Collections.Generic.IEnumerable.GetEnumerator
new IEnumerator< T > GetEnumerator()
System.Collections.Generic.IEnumerable
Definition
IEnumerable.cs:4
System.Collections.Generic.IEnumerator
Definition
IEnumerator.cs:4
System.Collections.Generic
Definition
IHashKeyCollection.cs:1
System.Collections
Definition
BlockingCollection.cs:8
System.Net.Http.Headers
Definition
AltSvcHeaderParser.cs:4
System.ExceptionArgument.list
@ list
System.ExceptionArgument.item
@ item
System.ExceptionArgument.arrayIndex
@ arrayIndex
System.ExceptionArgument.input
@ input
System.ExceptionArgument.array
@ array
System.ConsoleKey.T
@ T
System
Definition
BlockingCollection.cs:8
System.Net.Http.Headers.HeaderDescriptor
Definition
HeaderDescriptor.cs:9
source
System.Net.Http
System.Net.Http.Headers
HttpHeaderValueCollection.cs
Generated by
1.10.0