Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
MediaTypeHeaderValue.cs
Go to the documentation of this file.
4using System.Text;
5
7
9{
11
12 private string _mediaType;
13
14 public string? CharSet
15 {
16 get
17 {
18 return NameValueHeaderValue.Find(_parameters, "charset")?.Value;
19 }
20 set
21 {
23 if (string.IsNullOrEmpty(value))
24 {
25 if (nameValueHeaderValue != null)
26 {
28 }
29 }
30 else if (nameValueHeaderValue != null)
31 {
32 nameValueHeaderValue.Value = value;
33 }
34 else
35 {
37 }
38 }
39 }
40
42
43 public string? MediaType
44 {
45 get
46 {
47 return _mediaType;
48 }
50 set
51 {
54 }
55 }
56
58 {
59 }
60
62 {
63 _mediaType = source._mediaType;
64 _parameters = source._parameters.Clone();
65 }
66
67 public MediaTypeHeaderValue(string mediaType)
68 {
69 CheckMediaTypeFormat(mediaType, "mediaType");
70 _mediaType = mediaType;
71 }
72
84
85 public override bool Equals([NotNullWhen(true)] object? obj)
86 {
88 {
89 return false;
90 }
91 if (string.Equals(_mediaType, mediaTypeHeaderValue._mediaType, StringComparison.OrdinalIgnoreCase))
92 {
93 return HeaderUtilities.AreEqualCollections(_parameters, mediaTypeHeaderValue._parameters);
94 }
95 return false;
96 }
97
98 public override int GetHashCode()
99 {
101 }
102
103 public static MediaTypeHeaderValue Parse(string? input)
104 {
105 int index = 0;
107 }
108
109 public static bool TryParse([NotNullWhen(true)] string? input, [NotNullWhen(true)] out MediaTypeHeaderValue? parsedValue)
110 {
111 int index = 0;
112 parsedValue = null;
114 {
116 return true;
117 }
118 return false;
119 }
120
122 {
123 parsedValue = null;
124 if (string.IsNullOrEmpty(input) || startIndex >= input.Length)
125 {
126 return 0;
127 }
128 string mediaType;
131 {
132 return 0;
133 }
137 if (num < input.Length && input[num] == ';')
138 {
140 mediaTypeHeaderValue._mediaType = mediaType;
141 num++;
143 if (nameValueListLength == 0)
144 {
145 return 0;
146 }
148 return num + nameValueListLength - startIndex;
149 }
151 mediaTypeHeaderValue._mediaType = mediaType;
153 return num - startIndex;
154 }
155
156 private static int GetMediaTypeExpressionLength(string input, int startIndex, out string mediaType)
157 {
158 mediaType = null;
160 if (tokenLength == 0)
161 {
162 return 0;
163 }
164 int num = startIndex + tokenLength;
166 if (num >= input.Length || input[num] != '/')
167 {
168 return 0;
169 }
170 num++;
173 if (tokenLength2 == 0)
174 {
175 return 0;
176 }
177 int num2 = num + tokenLength2 - startIndex;
178 if (tokenLength + tokenLength2 + 1 == num2)
179 {
180 mediaType = input.Substring(startIndex, num2);
181 }
182 else
183 {
184 mediaType = string.Concat(input.AsSpan(startIndex, tokenLength), "/", input.AsSpan(num, tokenLength2));
185 }
186 return num2;
187 }
188
189 private static void CheckMediaTypeFormat(string mediaType, string parameterName)
190 {
191 if (string.IsNullOrEmpty(mediaType))
192 {
194 }
195 if (GetMediaTypeExpressionLength(mediaType, 0, out var mediaType2) == 0 || mediaType2.Length != mediaType.Length)
196 {
198 }
199 }
200
202 {
203 return new MediaTypeHeaderValue(this);
204 }
205}
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
void Add(TKey key, TValue value)
static CultureInfo InvariantCulture
static readonly MediaTypeHeaderParser SingleValueParser
static void CheckMediaTypeFormat(string mediaType, string parameterName)
static int GetMediaTypeLength(string input, int startIndex, Func< MediaTypeHeaderValue > mediaTypeCreator, out MediaTypeHeaderValue parsedValue)
ICollection< NameValueHeaderValue > Parameters
static MediaTypeHeaderValue Parse(string? input)
static int GetMediaTypeExpressionLength(string input, int startIndex, out string mediaType)
static bool TryParse([NotNullWhen(true)] string? input, [NotNullWhen(true)] out MediaTypeHeaderValue? parsedValue)
ObjectCollection< NameValueHeaderValue > _parameters
override bool Equals([NotNullWhen(true)] object? obj)
static int GetNameValueListLength(string input, int startIndex, char delimiter, ObjectCollection< NameValueHeaderValue > nameValueCollection)
static NameValueHeaderValue Find(ObjectCollection< NameValueHeaderValue > values, string name)
static int GetTokenLength(string input, int startIndex)
static int GetWhitespaceLength(string input, int startIndex)
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string net_http_headers_invalid_value
Definition SR.cs:26
static string net_http_argument_empty_string
Definition SR.cs:52
Definition SR.cs:7
static StringComparer OrdinalIgnoreCase
static string GetStringAndRelease(StringBuilder sb)
static StringBuilder Acquire(int capacity=16)