Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
CredentialKey.cs
Go to the documentation of this file.
4
5namespace System.Net;
6
7internal sealed class CredentialKey : IEquatable<CredentialKey>
8{
9 public readonly Uri UriPrefix;
10
11 public readonly int UriPrefixLength = -1;
12
13 public readonly string AuthenticationType;
14
15 internal CredentialKey(Uri uriPrefix, string authenticationType)
16 {
17 UriPrefix = uriPrefix;
19 AuthenticationType = authenticationType;
20 }
21
22 internal bool Match(Uri uri, string authenticationType)
23 {
24 if (uri == null || authenticationType == null)
25 {
26 return false;
27 }
28 if (!string.Equals(authenticationType, AuthenticationType, StringComparison.OrdinalIgnoreCase))
29 {
30 return false;
31 }
32 if (NetEventSource.Log.IsEnabled())
33 {
34 NetEventSource.Info(this, $"Match({UriPrefix} & {uri})", "Match");
35 }
36 return IsPrefix(uri, UriPrefix);
37 }
38
39 private static bool IsPrefix(Uri uri, Uri prefixUri)
40 {
41 if (prefixUri.Scheme != uri.Scheme || prefixUri.Host != uri.Host || prefixUri.Port != uri.Port)
42 {
43 return false;
44 }
45 int num = prefixUri.AbsolutePath.LastIndexOf('/');
46 if (num > uri.AbsolutePath.LastIndexOf('/'))
47 {
48 return false;
49 }
50 return string.Compare(uri.AbsolutePath, 0, prefixUri.AbsolutePath, 0, num, StringComparison.OrdinalIgnoreCase) == 0;
51 }
52
53 public override int GetHashCode()
54 {
56 }
57
58 public bool Equals([NotNullWhen(true)] CredentialKey other)
59 {
60 if (other == null)
61 {
62 return false;
63 }
64 bool flag = string.Equals(AuthenticationType, other.AuthenticationType, StringComparison.OrdinalIgnoreCase) && UriPrefix.Equals(other.UriPrefix);
65 if (NetEventSource.Log.IsEnabled())
66 {
67 NetEventSource.Info(this, $"Equals({this},{other}) returns {flag}", "Equals");
68 }
69 return flag;
70 }
71
72 public override bool Equals([NotNullWhen(true)] object obj)
73 {
74 return Equals(obj as CredentialKey);
75 }
76
77 public override string ToString()
78 {
80 DefaultInterpolatedStringHandler handler = new DefaultInterpolatedStringHandler(4, 3, invariantCulture);
81 handler.AppendLiteral("[");
83 handler.AppendLiteral("]:");
85 handler.AppendLiteral(":");
87 return string.Create(invariantCulture, ref handler);
88 }
89}
static CultureInfo InvariantCulture
readonly string AuthenticationType
bool Match(Uri uri, string authenticationType)
override bool Equals([NotNullWhen(true)] object obj)
override int GetHashCode()
bool Equals([NotNullWhen(true)] CredentialKey other)
static bool IsPrefix(Uri uri, Uri prefixUri)
override string ToString()
CredentialKey(Uri uriPrefix, string authenticationType)
static readonly System.Net.NetEventSource Log
static void Info(object thisOrContextObject, FormattableString formattableString=null, [CallerMemberName] string memberName=null)
static StringComparer OrdinalIgnoreCase
string Host
Definition Uri.cs:441
string AbsolutePath
Definition Uri.cs:239
override string ToString()
Definition Uri.cs:1119
override bool Equals([NotNullWhen(true)] object? comparand)
Definition Uri.cs:1166
string Scheme
Definition Uri.cs:505
int Port
Definition Uri.cs:453
override int GetHashCode()
Definition Uri.cs:1103