forked from pythonnet/pythonnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParameterHelper.cs
More file actions
46 lines (39 loc) · 1017 Bytes
/
ParameterHelper.cs
File metadata and controls
46 lines (39 loc) · 1017 Bytes
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
using System;
using System.Collections.Generic;
using System.Reflection;
namespace Python.Runtime.Reflection;
[Serializable]
struct ParameterHelper : IEquatable<ParameterInfo>
{
public readonly string TypeName;
public readonly ParameterModifier Modifier;
public ParameterHelper(ParameterInfo tp)
{
TypeName = tp.ParameterType.AssemblyQualifiedName;
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 bool Equals(ParameterInfo other)
{
return this.Equals(new ParameterHelper(other));
}
public bool Matches(ParameterInfo other) => this.Equals(other);
}
enum ParameterModifier
{
None,
In,
Out,
Ref
}