Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ RegisterPrefix()

static bool System.Net.WebRequest.RegisterPrefix ( string prefix,
IWebRequestCreate creator )
inlinestatic

Definition at line 323 of file WebRequest.cs.

324 {
325 bool flag = false;
326 if (prefix == null)
327 {
328 throw new ArgumentNullException("prefix");
329 }
330 if (creator == null)
331 {
332 throw new ArgumentNullException("creator");
333 }
335 {
337 if (Uri.TryCreate(prefix, UriKind.Absolute, out Uri result))
338 {
339 string text = result.AbsoluteUri;
340 if (!prefix.EndsWith('/') && result.GetComponents(UriComponents.PathAndQuery | UriComponents.Fragment, UriFormat.UriEscaped).Equals("/"))
341 {
342 text = text.Substring(0, text.Length - 1);
343 }
344 prefix = text;
345 }
346 int i;
347 for (i = 0; i < list.Count; i++)
348 {
349 WebRequestPrefixElement webRequestPrefixElement = list[i];
350 if (prefix.Length > webRequestPrefixElement.Prefix.Length)
351 {
352 break;
353 }
354 if (prefix.Length == webRequestPrefixElement.Prefix.Length && string.Equals(webRequestPrefixElement.Prefix, prefix, StringComparison.OrdinalIgnoreCase))
355 {
356 flag = true;
357 break;
358 }
359 }
360 if (!flag)
361 {
362 list.Insert(i, new WebRequestPrefixElement(prefix, creator));
364 }
365 }
366 return !flag;
367 }
static List< WebRequestPrefixElement > PrefixList
Definition WebRequest.cs:46
static object s_internalSyncObject
Definition WebRequest.cs:39
UriKind
Definition UriKind.cs:4
UriFormat
Definition UriFormat.cs:4

References System.Runtime.Serialization.Dictionary, System.list, System.prefix, System.Net.WebRequest.PrefixList, System.Net.WebRequest.s_internalSyncObject, System.text, and System.Uri.TryCreate().