FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
1script/src/ScriptEngine/Utils.cs at develop · xDrivenDevelopment/1script · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
xDrivenDevelopment
/
1script
Public
Notifications
You must be signed in to change notification settings
Fork
4
Star
16
Code
Pull requests
1
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
1script
/
src
/
ScriptEngine
/
Utils.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
68 lines (56 loc) · 1.85 KB
Breadcrumbs
1script
/
src
/
ScriptEngine
/
Utils.cs
Copy path
File metadata and controls
68 lines (56 loc) · 1.85 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using
System
;
using
System
.
Collections
.
Generic
;
using
System
.
Linq
;
using
System
.
Text
;
namespace
ScriptEngine
{
public
static
class
Utils
{
public
static
bool
IsValidIdentifier
(
string
name
)
{
if
(
name
==
null
||
name
.
Length
==
0
)
return
false
;
if
(
!
(
Char
.
IsLetter
(
name
[
0
]
)
||
name
[
0
]
==
'_'
)
)
return
false
;
for
(
int
i
=
1
;
i
<
name
.
Length
;
i
++
)
{
if
(
!
(
Char
.
IsLetterOrDigit
(
name
[
i
]
)
||
name
[
i
]
==
'_'
)
)
return
false
;
}
return
true
;
}
public
static
IEnumerable
<
string
>
SplitCommandLine
(
string
commandLine
)
{
bool
inQuotes
=
false
;
return
SplitString
(
commandLine
,
c
=>
{
if
(
c
==
'
\"
'
)
inQuotes
=
!
inQuotes
;
return
!
inQuotes
&&
c
==
' '
;
}
)
.
Select
(
arg
=>
arg
.
Trim
(
)
.
TrimMatchingQuotes
(
'
\"
'
)
)
.
Where
(
arg
=>
!
string
.
IsNullOrEmpty
(
arg
)
)
;
}
private
static
IEnumerable
<
string
>
SplitString
(
this
string
str
,
Func
<
char
,
bool
>
controller
)
{
int
nextPiece
=
0
;
for
(
int
c
=
0
;
c
<
str
.
Length
;
c
++
)
{
if
(
controller
(
str
[
c
]
)
)
{
yield
return
str
.
Substring
(
nextPiece
,
c
-
nextPiece
)
;
nextPiece
=
c
+
1
;
}
}
yield
return
str
.
Substring
(
nextPiece
)
;
}
private
static
string
TrimMatchingQuotes
(
this
string
input
,
char
quote
)
{
if
(
(
input
.
Length
>=
2
)
&&
(
input
[
0
]
==
quote
)
&&
(
input
[
input
.
Length
-
1
]
==
quote
)
)
return
input
.
Substring
(
1
,
input
.
Length
-
2
)
;
return
input
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL