Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
PasteArguments.cs
Go to the documentation of this file.
1
using
System.Text
;
2
3
namespace
System
;
4
5
internal
static
class
PasteArguments
6
{
7
internal
static
void
AppendArgument
(
ref
System
.
Text
.
ValueStringBuilder
stringBuilder
,
string
argument
)
8
{
9
if
(
stringBuilder
.Length != 0)
10
{
11
stringBuilder
.Append(
' '
);
12
}
13
if
(
argument
.Length != 0 &&
ContainsNoWhitespaceOrQuotes
(
argument
))
14
{
15
stringBuilder
.Append(
argument
);
16
return
;
17
}
18
stringBuilder
.Append(
'"'
);
19
int
num = 0;
20
while
(num <
argument
.Length)
21
{
22
char
c =
argument
[num++];
23
switch
(c)
24
{
25
case
'\\'
:
26
{
27
int
num2
= 1;
28
while
(num <
argument
.Length &&
argument
[num] ==
'\\'
)
29
{
30
num++;
31
num2
++;
32
}
33
if
(num ==
argument
.Length)
34
{
35
stringBuilder
.Append(
'\\'
,
num2
* 2);
36
}
37
else
if
(
argument
[num] ==
'"'
)
38
{
39
stringBuilder
.Append(
'\\'
,
num2
* 2 + 1);
40
stringBuilder
.Append(
'"'
);
41
num++;
42
}
43
else
44
{
45
stringBuilder
.Append(
'\\'
,
num2
);
46
}
47
break
;
48
}
49
case
'"'
:
50
stringBuilder
.Append(
'\\'
);
51
stringBuilder
.Append(
'"'
);
52
break
;
53
default
:
54
stringBuilder
.Append(c);
55
break
;
56
}
57
}
58
stringBuilder
.Append(
'"'
);
59
}
60
61
private
static
bool
ContainsNoWhitespaceOrQuotes
(
string
s
)
62
{
63
foreach
(
char
c
in
s
)
64
{
65
if
(
char
.IsWhiteSpace(c) || c ==
'"'
)
66
{
67
return
false
;
68
}
69
}
70
return
true
;
71
}
72
}
System.Collections.Generic.Dictionary
Definition
Dictionary.cs:14
System.PasteArguments.AppendArgument
static void AppendArgument(ref System.Text.ValueStringBuilder stringBuilder, string argument)
Definition
PasteArguments.cs:7
System.PasteArguments.ContainsNoWhitespaceOrQuotes
static bool ContainsNoWhitespaceOrQuotes(string s)
Definition
PasteArguments.cs:61
System.PasteArguments
Definition
PasteArguments.cs:6
System.Text
Definition
ConsoleEncoding.cs:1
System.ExceptionArgument.s
@ s
System
Definition
BlockingCollection.cs:8
System.Text.ValueStringBuilder
Definition
ValueStringBuilder.cs:10
source
System.Diagnostics.Process
System
PasteArguments.cs
Generated by
1.10.0