Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
WebSocketValidate.cs
Go to the documentation of this file.
1
namespace
System.Net.WebSockets
;
2
3
internal
static
class
WebSocketValidate
4
{
5
internal
static
void
ValidateSubprotocol
(
string
subProtocol)
6
{
7
if
(
string
.IsNullOrWhiteSpace(subProtocol))
8
{
9
throw
new
ArgumentException
(
System
.
SR
.
net_WebSockets_InvalidEmptySubProtocol
,
"subProtocol"
);
10
}
11
string
text
=
null
;
12
for
(
int
i = 0; i < subProtocol.Length; i++)
13
{
14
char
c = subProtocol[i];
15
if
(c <
'!'
|| c >
'~'
)
16
{
17
text
= $
"[{c}]"
;
18
break
;
19
}
20
if
(!
char
.IsLetterOrDigit(c) &&
"()<>@,;:\\\"/[]?={} "
.IndexOf(c) >= 0)
21
{
22
text
= c.ToString();
23
break
;
24
}
25
}
26
if
(
text
!=
null
)
27
{
28
throw
new
ArgumentException
(
System
.
SR
.
Format
(
System
.
SR
.
net_WebSockets_InvalidCharInProtocolString
, subProtocol,
text
),
"subProtocol"
);
29
}
30
}
31
32
internal
static
void
ValidateArraySegment
(
ArraySegment<byte>
arraySegment,
string
parameterName)
33
{
34
if
(arraySegment.
Array
==
null
)
35
{
36
throw
new
ArgumentNullException
(parameterName +
".Array"
);
37
}
38
if
(arraySegment.
Offset
< 0 || arraySegment.
Offset
> arraySegment.
Array
.Length)
39
{
40
throw
new
ArgumentOutOfRangeException
(parameterName +
".Offset"
);
41
}
42
if
(arraySegment.
Count
< 0 || arraySegment.
Count
> arraySegment.
Array
.Length - arraySegment.
Offset
)
43
{
44
throw
new
ArgumentOutOfRangeException
(parameterName +
".Count"
);
45
}
46
}
47
}
System.ArgumentException
Definition
ArgumentException.cs:9
System.ArgumentNullException
Definition
ArgumentNullException.cs:10
System.ArgumentOutOfRangeException
Definition
ArgumentOutOfRangeException.cs:9
System.Net.WebSockets.WebSocketValidate.ValidateSubprotocol
static void ValidateSubprotocol(string subProtocol)
Definition
WebSocketValidate.cs:5
System.Net.WebSockets.WebSocketValidate.ValidateArraySegment
static void ValidateArraySegment(ArraySegment< byte > arraySegment, string parameterName)
Definition
WebSocketValidate.cs:32
System.SR.net_WebSockets_InvalidCharInProtocolString
static string net_WebSockets_InvalidCharInProtocolString
Definition
SR.cs:138
System.SR.Format
static string Format(string resourceFormat, object p1)
Definition
SR.cs:118
System.SR.net_WebSockets_InvalidEmptySubProtocol
static string net_WebSockets_InvalidEmptySubProtocol
Definition
SR.cs:136
System.SR
Definition
SR.cs:7
System.Net.WebSockets
Definition
HttpListenerWebSocketContext.cs:5
System.ExceptionArgument.text
@ text
System
Definition
BlockingCollection.cs:8
System.ArraySegment.Offset
int Offset
Definition
ArraySegment.cs:79
System.ArraySegment.Array
T?[] Array
Definition
ArraySegment.cs:77
System.ArraySegment.Count
int Count
Definition
ArraySegment.cs:81
System.ArraySegment
Definition
ArraySegment.cs:11
source
System.Net.WebSockets.Client
System.Net.WebSockets
WebSocketValidate.cs
Generated by
1.10.0