Lean  $LEAN_TAG$
QuantConnect.Python.BasePythonWrapper< TInterface >.PythonRuntimeChecker Class Reference

Set of helper methods to invoke Python methods with runtime checks for return values and out parameter's conversions. More...

Static Public Member Functions

static TResult InvokeMethod< TResult > (PyObject method, string pythonMethodName, params object[] args)
 Invokes method method and converts the returned value to type TResult More...
 
static IEnumerable< TItem > InvokeMethodAndEnumerate< TItem > (PyObject method, string pythonMethodName, params object[] args)
 Invokes method method , expecting an enumerable or generator as return value, converting each item to type TItem on demand. More...
 
static Dictionary< TKey, TValue > InvokeMethodAndGetDictionary< TKey, TValue > (PyObject method, string pythonMethodName, params object[] args)
 Invokes method method , expecting a dictionary as return value, which then will be converted to a managed dictionary, with type checking on each item conversion. More...
 
static TResult InvokeMethodAndWrapResult< TResult > (PyObject method, string pythonMethodName, Func< PyObject, TResult > wrapResult, params object[] args)
 Invokes method method and tries to convert the returned value to type TResult . If conversion is not possible, the returned PyObject is passed to the provided wrapResult method, which should try to do the proper conversion, wrapping or handling of the PyObject. More...
 
static TResult InvokeMethodAndGetOutParameters< TResult > (PyObject method, string pythonMethodName, Type[] outParametersTypes, out object[] outParameters, params object[] args)
 Invokes method method and converts the returned value to type TResult . It also makes sure the Python method returns values for the out parameters, converting them into the expected types in outParametersTypes and placing them in the outParameters array. More...
 
static T Convert< T > (PyObject pyObject, string pythonName, bool isMethod=true)
 Converts the given PyObject into the provided T type, generating an exception with a user-friendly message if conversion is not possible. More...
 
static T ConvertAndDispose< T > (PyObject pyObject, string pythonName, bool isMethod=true)
 Converts the given PyObject into the provided T type, generating an exception with a user-friendly message if conversion is not possible. It will dispose of the source PyObject. More...
 

Detailed Description

Set of helper methods to invoke Python methods with runtime checks for return values and out parameter's conversions.

Definition at line 336 of file BasePythonWrapper.cs.

Member Function Documentation

◆ InvokeMethod< TResult >()

static TResult QuantConnect.Python.BasePythonWrapper< TInterface >.PythonRuntimeChecker.InvokeMethod< TResult > ( PyObject  method,
string  pythonMethodName,
params object[]  args 
)
static

Invokes method method and converts the returned value to type TResult

Definition at line 341 of file BasePythonWrapper.cs.

◆ InvokeMethodAndEnumerate< TItem >()

static IEnumerable<TItem> QuantConnect.Python.BasePythonWrapper< TInterface >.PythonRuntimeChecker.InvokeMethodAndEnumerate< TItem > ( PyObject  method,
string  pythonMethodName,
params object[]  args 
)
static

Invokes method method , expecting an enumerable or generator as return value, converting each item to type TItem on demand.

Definition at line 353 of file BasePythonWrapper.cs.

◆ InvokeMethodAndGetDictionary< TKey, TValue >()

static Dictionary<TKey, TValue> QuantConnect.Python.BasePythonWrapper< TInterface >.PythonRuntimeChecker.InvokeMethodAndGetDictionary< TKey, TValue > ( PyObject  method,
string  pythonMethodName,
params object[]  args 
)
static

Invokes method method , expecting a dictionary as return value, which then will be converted to a managed dictionary, with type checking on each item conversion.

Definition at line 370 of file BasePythonWrapper.cs.

◆ InvokeMethodAndWrapResult< TResult >()

static TResult QuantConnect.Python.BasePythonWrapper< TInterface >.PythonRuntimeChecker.InvokeMethodAndWrapResult< TResult > ( PyObject  method,
string  pythonMethodName,
Func< PyObject, TResult >  wrapResult,
params object[]  args 
)
static

Invokes method method and tries to convert the returned value to type TResult . If conversion is not possible, the returned PyObject is passed to the provided wrapResult method, which should try to do the proper conversion, wrapping or handling of the PyObject.

Definition at line 409 of file BasePythonWrapper.cs.

◆ InvokeMethodAndGetOutParameters< TResult >()

static TResult QuantConnect.Python.BasePythonWrapper< TInterface >.PythonRuntimeChecker.InvokeMethodAndGetOutParameters< TResult > ( PyObject  method,
string  pythonMethodName,
Type[]  outParametersTypes,
out object[]  outParameters,
params object[]  args 
)
static

Invokes method method and converts the returned value to type TResult . It also makes sure the Python method returns values for the out parameters, converting them into the expected types in outParametersTypes and placing them in the outParameters array.

Definition at line 429 of file BasePythonWrapper.cs.

◆ Convert< T >()

static T QuantConnect.Python.BasePythonWrapper< TInterface >.PythonRuntimeChecker.Convert< T > ( PyObject  pyObject,
string  pythonName,
bool  isMethod = true 
)
static

Converts the given PyObject into the provided T type, generating an exception with a user-friendly message if conversion is not possible.

Definition at line 474 of file BasePythonWrapper.cs.

Here is the caller graph for this function:

◆ ConvertAndDispose< T >()

static T QuantConnect.Python.BasePythonWrapper< TInterface >.PythonRuntimeChecker.ConvertAndDispose< T > ( PyObject  pyObject,
string  pythonName,
bool  isMethod = true 
)
static

Converts the given PyObject into the provided T type, generating an exception with a user-friendly message if conversion is not possible. It will dispose of the source PyObject.

Definition at line 502 of file BasePythonWrapper.cs.

Here is the call graph for this function:

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