FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pythonnet/src/runtime/CollectionWrappers/IterableWrapper.cs at master · ZeroMSN/pythonnet · GitHub
ZeroMSN
pythonnet
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
pythonnet
/
src
/
runtime
/
CollectionWrappers
/
IterableWrapper.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
46 lines (42 loc) · 1.16 KB
Breadcrumbs
pythonnet
/
src
/
runtime
/
CollectionWrappers
/
IterableWrapper.cs
Copy path
File metadata and controls
46 lines (42 loc) · 1.16 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
using
System
;
using
System
.
Collections
.
Generic
;
using
System
.
Collections
;
namespace
Python
.
Runtime
.
CollectionWrappers
{
internal
class
IterableWrapper
<
T
>
:
IEnumerable
<
T
>
{
protected
readonly
PyObject
pyObject
;
public
IterableWrapper
(
PyObject
pyObj
)
{
if
(
pyObj
==
null
)
throw
new
ArgumentNullException
(
)
;
pyObject
=
new
PyObject
(
pyObj
.
Reference
)
;
}
IEnumerator
IEnumerable
.
GetEnumerator
(
)
=>
GetEnumerator
(
)
;
public
IEnumerator
<
T
>
GetEnumerator
(
)
{
PyIter
iterObject
;
using
(
Py
.
GIL
(
)
)
{
iterObject
=
PyIter
.
GetIter
(
pyObject
)
;
}
try
{
while
(
true
)
{
using
var
_
=
Py
.
GIL
(
)
;
if
(
!
iterObject
.
MoveNext
(
)
)
{
break
;
}
yield
return
iterObject
.
Current
.
As
<
T
>
(
)
!
;
}
}
finally
{
using
var
_
=
Py
.
GIL
(
)
;
iterObject
.
Dispose
(
)
;
}
}
}
}
Back
|
FazBrowse Home
|
New Git URL