Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
StringBuilderExtensions.cs
Go to the documentation of this file.
1
using
System.Text
;
2
3
namespace
System.Net.Http
;
4
5
internal
static
class
StringBuilderExtensions
6
{
7
private
static
readonly
char
[]
SpecialCharacters
=
new
char
[2] {
'"'
,
'\\'
};
8
9
public
static
void
AppendKeyValue
(
this
StringBuilder
sb,
string
key
,
string
value
,
bool
includeQuotes =
true
,
bool
includeComma =
true
)
10
{
11
sb.
Append
(
key
);
12
sb.
Append
(
'='
);
13
if
(includeQuotes)
14
{
15
sb.
Append
(
'"'
);
16
int
num = 0;
17
while
(
true
)
18
{
19
int
num2 =
value
.IndexOfAny(
SpecialCharacters
, num);
20
if
(num2 < 0)
21
{
22
break
;
23
}
24
sb.
Append
(
value
, num, num2 - num);
25
sb.
Append
(
'\\'
);
26
sb.
Append
(
value
[num2]);
27
num = num2 + 1;
28
}
29
sb.
Append
(
value
, num,
value
.Length - num);
30
sb.
Append
(
'"'
);
31
}
32
else
33
{
34
sb.
Append
(
value
);
35
}
36
if
(includeComma)
37
{
38
sb.
Append
(
','
);
39
sb.
Append
(
' '
);
40
}
41
}
42
}
System.Net.Http.StringBuilderExtensions.SpecialCharacters
static readonly char[] SpecialCharacters
Definition
StringBuilderExtensions.cs:7
System.Net.Http.StringBuilderExtensions.AppendKeyValue
static void AppendKeyValue(this StringBuilder sb, string key, string value, bool includeQuotes=true, bool includeComma=true)
Definition
StringBuilderExtensions.cs:9
System.Net.Http.StringBuilderExtensions
Definition
StringBuilderExtensions.cs:6
System.Text.StringBuilder.Append
StringBuilder Append(char value, int repeatCount)
Definition
StringBuilder.cs:744
System.Text.StringBuilder
Definition
StringBuilder.cs:14
System.Net.Http
Definition
HttpClientJsonExtensions.cs:8
System.Text
Definition
ConsoleEncoding.cs:1
System.ExceptionArgument.value
@ value
System.ExceptionArgument.key
@ key
source
System.Net.Http
System.Net.Http
StringBuilderExtensions.cs
Generated by
1.10.0