FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pythonnet/src/runtime/Util/ParameterHelper.cs at v3.0.1 · pythonnet/pythonnet · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
pythonnet
/
pythonnet
Public
Notifications
You must be signed in to change notification settings
Fork
780
Star
5.5k
Code
Issues
153
Pull requests
12
Discussions
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
pythonnet
/
src
/
runtime
/
Util
/
ParameterHelper.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
91 lines (77 loc) · 2.45 KB
Breadcrumbs
pythonnet
/
src
/
runtime
/
Util
/
ParameterHelper.cs
Copy path
File metadata and controls
91 lines (77 loc) · 2.45 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
using
System
;
using
System
.
Collections
.
Generic
;
using
System
.
Diagnostics
;
using
System
.
Linq
;
using
System
.
Reflection
;
namespace
Python
.
Runtime
.
Reflection
;
[
Serializable
]
class
ParameterHelper
:
IEquatable
<
ParameterInfo
>
{
public
readonly
string
TypeName
;
public
readonly
ParameterModifier
Modifier
;
public
readonly
ParameterHelper
[
]
?
GenericArguments
;
public
ParameterHelper
(
ParameterInfo
tp
)
:
this
(
tp
.
ParameterType
)
{
Modifier
=
ParameterModifier
.
None
;
if
(
tp
.
IsIn
&&
tp
.
ParameterType
.
IsByRef
)
{
Modifier
=
ParameterModifier
.
In
;
}
else
if
(
tp
.
IsOut
&&
tp
.
ParameterType
.
IsByRef
)
{
Modifier
=
ParameterModifier
.
Out
;
}
else
if
(
tp
.
ParameterType
.
IsByRef
)
{
Modifier
=
ParameterModifier
.
Ref
;
}
}
public
ParameterHelper
(
Type
type
)
{
TypeName
=
type
.
AssemblyQualifiedName
;
if
(
TypeName
is
null
)
{
if
(
type
.
IsByRef
||
type
.
IsArray
)
{
TypeName
=
type
.
IsArray
?
"[]"
:
"&"
;
GenericArguments
=
new
[
]
{
new
ParameterHelper
(
type
.
GetElementType
(
)
)
}
;
}
else
{
Debug
.
Assert
(
type
.
ContainsGenericParameters
)
;
TypeName
=
$
"
{
type
.
Assembly
}
::
{
type
.
Namespace
}
/
{
type
.
Name
}
"
;
GenericArguments
=
type
.
GenericTypeArguments
.
Select
(
t
=>
new
ParameterHelper
(
t
)
)
.
ToArray
(
)
;
}
}
}
public
bool
IsSpecialType
=>
TypeName
==
"&"
||
TypeName
==
"[]"
;
public
bool
Equals
(
ParameterInfo
other
)
{
return
this
.
Equals
(
new
ParameterHelper
(
other
)
)
;
}
public
bool
Matches
(
ParameterInfo
other
)
=>
this
.
Equals
(
other
)
;
public
bool
Equals
(
ParameterHelper
other
)
{
if
(
other
is
null
)
return
false
;
if
(
!
(
other
.
TypeName
==
TypeName
&&
other
.
Modifier
==
Modifier
)
)
return
false
;
if
(
GenericArguments
==
other
.
GenericArguments
)
return
true
;
if
(
GenericArguments
is
not
null
&&
other
.
GenericArguments
is
not
null
)
{
if
(
GenericArguments
.
Length
!=
other
.
GenericArguments
.
Length
)
return
false
;
for
(
int
arg
=
0
;
arg
<
GenericArguments
.
Length
;
arg
++
)
{
if
(
!
GenericArguments
[
arg
]
.
Equals
(
other
.
GenericArguments
[
arg
]
)
)
return
false
;
}
return
true
;
}
return
false
;
}
}
enum
ParameterModifier
{
None
,
In
,
Out
,
Ref
}
Back
|
FazBrowse Home
|
New Git URL