11 private string _LowerCaseScheme;
13 private string _LowerCasePort;
17 private const string DefaultStr =
"$default";
19 private const string OriginStr =
"$origin";
21 internal const int NoPort = -1;
23 internal const int AnyPort = -2;
39 public string Scheme => _LowerCaseScheme;
43 public int Port => _IntPort;
45 internal bool IsOriginScheme => (object)_LowerCaseScheme ==
OriginScheme;
47 internal bool IsAnyScheme => (object)_LowerCaseScheme ==
AnyScheme;
53 internal string StrPort => _LowerCasePort;
66 if (!IsValidScheme(allowScheme))
82 codeConnectAccess.SetCodeConnectAccess(
OriginScheme, allowPort);
83 return codeConnectAccess;
95 codeConnectAccess.SetCodeConnectAccess(
AnyScheme, allowPort);
96 return codeConnectAccess;
103 private void SetCodeConnectAccess(
string lowerCaseScheme,
int allowPort)
105 _LowerCaseScheme = lowerCaseScheme;
108 _LowerCasePort =
"$default";
112 _LowerCasePort =
"$origin";
116 if (allowPort < 0 || allowPort > 65535)
118 throw new ArgumentOutOfRangeException(
"allowPort");
122 _IntPort = allowPort;
136 if (codeConnectAccess ==
null)
142 return Port == codeConnectAccess.
Port;
151 return Scheme.GetHashCode() +
Port.GetHashCode();
156 if (allowScheme ==
null || allowScheme.Length == 0)
160 if (allowPort ==
null || allowPort.Length == 0)
173 else if (!IsValidScheme(_LowerCaseScheme))
175 throw new ArgumentOutOfRangeException(
"allowScheme");
178 if (_LowerCasePort ==
"$default")
183 if (_LowerCasePort ==
"$origin")
189 if (_IntPort < 0 || _IntPort > 65535)
191 throw new ArgumentOutOfRangeException(
"allowPort");
196 internal static bool IsValidScheme(
string scheme)
198 if (scheme ==
null || scheme.Length == 0 || !IsAsciiLetter(scheme[0]))
202 for (
int num = scheme.Length - 1; num > 0; num--)
204 if (!IsAsciiLetterOrDigit(scheme[num]) && scheme[num] !=
'+' && scheme[num] !=
'-' && scheme[num] !=
'.')
212 private static bool IsAsciiLetterOrDigit(
char character)
214 if (!IsAsciiLetter(character))
216 if (character >=
'0')
218 return character <=
'9';
225 private static bool IsAsciiLetter(
char character)
227 if (character < 'a' || character >
'z')
229 if (character >=
'A')
231 return character <=
'Z';
static CultureInfo InvariantCulture
Gets the T:System.Globalization.CultureInfo object that is culture-independent (invariant).
static readonly int OriginPort
Contains the value used to represent the port value in the URI where code originated.
override int GetHashCode()
Serves as a hash function for a particular type.
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
static readonly string OriginScheme
Contains the value used to represent the scheme in the URL where the code originated.
The exception that is thrown when the value of an argument is outside the allowable range of values a...
static readonly int DefaultPort
Contains the value used to represent the default port.
CodeConnectAccess(string allowScheme, int allowPort)
Initializes a new instance of the T:System.Security.Policy.CodeConnectAccess class.
static readonly string AnyScheme
Contains the string value that represents the scheme wildcard.
Specifies the network resource access that is granted to code.
static CodeConnectAccess CreateAnySchemeAccess(int allowPort)
Returns a T:System.Security.Policy.CodeConnectAccess instance that represents access to the specified...
override bool Equals(object o)
Returns a value indicating whether two T:System.Security.Policy.CodeConnectAccess objects represent t...
Specifies that the class can be serialized.
static CodeConnectAccess CreateOriginSchemeAccess(int allowPort)
Returns a T:System.Security.Policy.CodeConnectAccess instance that represents access to the specified...
Provides information about a specific culture (called a locale for unmanaged code development)....
string Scheme
Gets the URI scheme represented by the current instance.
int Port
Gets the port represented by the current instance.