MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
Python.Runtime.PyConverter Class Reference

use PyConverter to convert between python object and clr object. More...

Public Member Functions

 PyConverter ()
 Constructor More...
 
void Add (PyClrTypeBase converter)
 Add a new type for conversion. More...
 
void AddObjectType< T > (PyObject pyType, PyConverter converter=null)
 Add a new PyObjec type to the converter. More...
 
void AddListType (PyConverter converter=null)
 Add a new list type to the converter. More...
 
void AddListType< T > (PyConverter converter=null)
 Add a new list type to the converter. More...
 
void AddDictType< K, V > (PyConverter converter=null)
 Add a new dictionary type of K key types and V value types. More...
 
ToClr< T > (PyObject obj)
 Convert the PyObject to a specifict type T More...
 
object ToClr (PyObject obj, Type t=null)
 Convert a PyObject to a clr type of 't'. More...
 
PyObject ToPython (object clrObj, IntPtr? t=null)
 Convert a clr object to a PyObject. More...
 

Detailed Description

use PyConverter to convert between python object and clr object.

Open-source public code originally shared from:

See also
PyConverter by Wenguang Yang, 2018

Definition at line 15 of file PyConverter.cs.

Constructor & Destructor Documentation

◆ PyConverter()

Python.Runtime.PyConverter.PyConverter ( )

Constructor

Definition at line 20 of file PyConverter.cs.

Member Function Documentation

◆ Add()

void Python.Runtime.PyConverter.Add ( PyClrTypeBase  converter)

Add a new type for conversion.

Parameters
converterSpecifies the converter.

Definition at line 37 of file PyConverter.cs.

◆ AddDictType< K, V >()

void Python.Runtime.PyConverter.AddDictType< K, V > ( PyConverter  converter = null)

Add a new dictionary type of K key types and V value types.

Template Parameters
KSpecifies the key type.
VSpecifies the value type.
Parameters
converterSpecifies the converter.

Definition at line 104 of file PyConverter.cs.

◆ AddListType()

void Python.Runtime.PyConverter.AddListType ( PyConverter  converter = null)

Add a new list type to the converter.

Parameters
converterSpecifies the converter.

Definition at line 79 of file PyConverter.cs.

◆ AddListType< T >()

void Python.Runtime.PyConverter.AddListType< T > ( PyConverter  converter = null)

Add a new list type to the converter.

Template Parameters
TSpecifies the element type.
Parameters
converterSpecifies the converter.

Definition at line 89 of file PyConverter.cs.

◆ AddObjectType< T >()

void Python.Runtime.PyConverter.AddObjectType< T > ( PyObject  pyType,
PyConverter  converter = null 
)

Add a new PyObjec type to the converter.

Template Parameters
T
Parameters
pyTypeSpecifies the type to add.
converterSpecifies the converter.

Definition at line 66 of file PyConverter.cs.

◆ ToClr()

object Python.Runtime.PyConverter.ToClr ( PyObject  obj,
Type  t = null 
)

Convert a PyObject to a clr type of 't'.

Parameters
objSpecifies the PyObject to convert.
tSpecifies the expected clr type.
Returns
The clr object is returned.

Definition at line 130 of file PyConverter.cs.

◆ ToClr< T >()

T Python.Runtime.PyConverter.ToClr< T > ( PyObject  obj)

Convert the PyObject to a specifict type T

Template Parameters
TSpecifies the type to convert to.
Parameters
objSpecifies the PyObject to convert.
Returns
The clr object is returned.

Definition at line 119 of file PyConverter.cs.

◆ ToPython()

PyObject Python.Runtime.PyConverter.ToPython ( object  clrObj,
IntPtr?  t = null 
)

Convert a clr object to a PyObject.

Parameters
clrObjSpecifies the clr object to covert.
tSpecifies the expected Python type.
Returns
The converted PyObject is returned.
Exceptions
ExceptionAn exception is thrown on error.

Definition at line 160 of file PyConverter.cs.


The documentation for this class was generated from the following file: