FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pythonnet/src/runtime/PythonTypes/PyObject.IConvertible.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
/
PythonTypes
/
PyObject.IConvertible.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
53 lines (44 loc) · 1.87 KB
Breadcrumbs
pythonnet
/
src
/
runtime
/
PythonTypes
/
PyObject.IConvertible.cs
Copy path
File metadata and controls
53 lines (44 loc) · 1.87 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
using
System
;
namespace
Python
.
Runtime
;
public
partial
class
PyObject
:
IConvertible
{
public
virtual
TypeCode
GetTypeCode
(
)
=>
TypeCode
.
Object
;
private
T
DoConvert
<
T
>
(
)
{
using
var
_
=
Py
.
GIL
(
)
;
if
(
Converter
.
ToPrimitive
(
Reference
,
typeof
(
T
)
,
out
object
?
result
,
setError
:
false
)
)
{
return
(
T
)
result
!
;
}
else
{
throw
new
InvalidCastException
(
)
;
}
}
public
bool
ToBoolean
(
IFormatProvider
provider
)
=>
DoConvert
<
bool
>
(
)
;
public
byte
ToByte
(
IFormatProvider
provider
)
=>
DoConvert
<
byte
>
(
)
;
public
char
ToChar
(
IFormatProvider
provider
)
=>
DoConvert
<
char
>
(
)
;
public
short
ToInt16
(
IFormatProvider
provider
)
=>
DoConvert
<
short
>
(
)
;
public
int
ToInt32
(
IFormatProvider
provider
)
=>
DoConvert
<
int
>
(
)
;
public
long
ToInt64
(
IFormatProvider
provider
)
=>
DoConvert
<
long
>
(
)
;
public
sbyte
ToSByte
(
IFormatProvider
provider
)
=>
DoConvert
<
sbyte
>
(
)
;
public
ushort
ToUInt16
(
IFormatProvider
provider
)
=>
DoConvert
<
ushort
>
(
)
;
public
uint
ToUInt32
(
IFormatProvider
provider
)
=>
DoConvert
<
uint
>
(
)
;
public
ulong
ToUInt64
(
IFormatProvider
provider
)
=>
DoConvert
<
ulong
>
(
)
;
public
float
ToSingle
(
IFormatProvider
provider
)
=>
DoConvert
<
float
>
(
)
;
public
double
ToDouble
(
IFormatProvider
provider
)
=>
DoConvert
<
double
>
(
)
;
public
string
ToString
(
IFormatProvider
provider
)
=>
DoConvert
<
string
>
(
)
;
public
DateTime
ToDateTime
(
IFormatProvider
provider
)
=>
throw
new
InvalidCastException
(
)
;
public
decimal
ToDecimal
(
IFormatProvider
provider
)
=>
throw
new
InvalidCastException
(
)
;
public
object
ToType
(
Type
conversionType
,
IFormatProvider
provider
)
{
if
(
Converter
.
ToManaged
(
Reference
,
conversionType
,
out
object
?
result
,
setError
:
false
)
)
{
return
result
!
;
}
else
{
throw
new
InvalidCastException
(
)
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL