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

Base class for Python wrapper classes More...

Inheritance diagram for QuantConnect.Python.BasePythonWrapper< TInterface >:
[legend]

Classes

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

Public Member Functions

 BasePythonWrapper (bool validateInterface=true)
 Creates a new instance of the BasePythonWrapper<TInterface> class More...
 
 BasePythonWrapper (PyObject instance, bool validateInterface=true)
 Creates a new instance of the BasePythonWrapper<TInterface> class with the specified instance More...
 
void SetPythonInstance (PyObject instance)
 Sets the python instance More...
 
GetProperty< T > (string propertyName)
 Gets the Python instance property with the specified name More...
 
PyObject GetProperty (string propertyName)
 Gets the Python instance property with the specified name More...
 
void SetProperty (string propertyName, object value)
 Sets the Python instance property with the specified name More...
 
dynamic GetEvent (string name)
 Gets the Python instance event with the specified name More...
 
bool HasAttr (string name)
 Determines whether the Python instance has the specified attribute More...
 
PyObject GetMethod (string methodName)
 Gets the Python instances method with the specified name and caches it More...
 
InvokeMethod< T > (string methodName, params object[] args)
 Invokes the specified method with the specified arguments More...
 
PyObject InvokeMethod (string methodName, params object[] args)
 Invokes the specified method with the specified arguments More...
 
void InvokeVoidMethod (string methodName, params object[] args)
 Invokes the specified method with the specified arguments without returning a value More...
 
IEnumerable< T > InvokeMethodAndEnumerate< T > (string methodName, params object[] args)
 Invokes the specified method with the specified arguments and iterates over the returned values More...
 
Dictionary< TKey, TValue > InvokeMethodAndGetDictionary< TKey, TValue > (string methodName, params object[] args)
 Invokes the specified method with the specified arguments and iterates over the returned values More...
 
InvokeMethodWithOutParameters< T > (string methodName, Type[] outParametersTypes, out object[] outParameters, params object[] args)
 Invokes the specified method with the specified arguments and out parameters More...
 
InvokeMethodAndWrapResult< T > (string methodName, Func< PyObject, T > wrapResult, params object[] args)
 Invokes the specified method with the specified arguments and wraps the result by calling the given function if the result is not a C# object More...
 
virtual bool Equals (BasePythonWrapper< TInterface > other)
 Determines whether the specified instance wraps the same Python object reference as this instance, which would indicate that they are equal. More...
 
override bool Equals (object obj)
 Determines whether the specified object is an instance of BasePythonWrapper<TInterface> and wraps the same Python object reference as this instance, which would indicate that they are equal. More...
 
override int GetHashCode ()
 Gets the hash code for the current instance More...
 

Protected Attributes

PyObject Instance => _instance
 Gets the underlying python instance More...
 

Detailed Description

Base class for Python wrapper classes

Definition at line 25 of file BasePythonWrapper.cs.

Constructor & Destructor Documentation

◆ BasePythonWrapper() [1/2]

QuantConnect.Python.BasePythonWrapper< TInterface >.BasePythonWrapper ( bool  validateInterface = true)

Creates a new instance of the BasePythonWrapper<TInterface> class

Parameters
validateInterfaceWhether to perform validations for interface implementation

Definition at line 43 of file BasePythonWrapper.cs.

◆ BasePythonWrapper() [2/2]

QuantConnect.Python.BasePythonWrapper< TInterface >.BasePythonWrapper ( PyObject  instance,
bool  validateInterface = true 
)

Creates a new instance of the BasePythonWrapper<TInterface> class with the specified instance

Parameters
instanceThe underlying python instance
validateInterfaceWhether to perform validations for interface implementation

Definition at line 55 of file BasePythonWrapper.cs.

Member Function Documentation

◆ SetPythonInstance()

void QuantConnect.Python.BasePythonWrapper< TInterface >.SetPythonInstance ( PyObject  instance)

Sets the python instance

Parameters
instanceThe underlying python instance

Definition at line 65 of file BasePythonWrapper.cs.

Here is the caller graph for this function:

◆ GetProperty< T >()

T QuantConnect.Python.BasePythonWrapper< TInterface >.GetProperty< T > ( string  propertyName)

Gets the Python instance property with the specified name

Parameters
propertyNameThe name of the property

Definition at line 81 of file BasePythonWrapper.cs.

◆ GetProperty()

PyObject QuantConnect.Python.BasePythonWrapper< TInterface >.GetProperty ( string  propertyName)

Gets the Python instance property with the specified name

Parameters
propertyNameThe name of the property

Definition at line 91 of file BasePythonWrapper.cs.

Here is the caller graph for this function:

◆ SetProperty()

void QuantConnect.Python.BasePythonWrapper< TInterface >.SetProperty ( string  propertyName,
object  value 
)

Sets the Python instance property with the specified name

Parameters
propertyNameThe name of the property
valueThe property value

Definition at line 102 of file BasePythonWrapper.cs.

◆ GetEvent()

dynamic QuantConnect.Python.BasePythonWrapper< TInterface >.GetEvent ( string  name)

Gets the Python instance event with the specified name

Parameters
nameThe name of the event

Definition at line 112 of file BasePythonWrapper.cs.

◆ HasAttr()

bool QuantConnect.Python.BasePythonWrapper< TInterface >.HasAttr ( string  name)

Determines whether the Python instance has the specified attribute

Parameters
nameThe attribute name
Returns
Whether the Python instance has the specified attribute

Definition at line 123 of file BasePythonWrapper.cs.

Here is the caller graph for this function:

◆ GetMethod()

PyObject QuantConnect.Python.BasePythonWrapper< TInterface >.GetMethod ( string  methodName)

Gets the Python instances method with the specified name and caches it

Parameters
methodNameThe name of the method
Returns
The matched method

Definition at line 134 of file BasePythonWrapper.cs.

Here is the caller graph for this function:

◆ InvokeMethod< T >()

T QuantConnect.Python.BasePythonWrapper< TInterface >.InvokeMethod< T > ( string  methodName,
params object[]  args 
)

Invokes the specified method with the specified arguments

Parameters
methodNameThe name of the method
argsThe arguments to call the method with
Returns
The returned valued converted to the given type

Definition at line 151 of file BasePythonWrapper.cs.

◆ InvokeMethod()

PyObject QuantConnect.Python.BasePythonWrapper< TInterface >.InvokeMethod ( string  methodName,
params object[]  args 
)

Invokes the specified method with the specified arguments

Parameters
methodNameThe name of the method
argsThe arguments to call the method with

Definition at line 162 of file BasePythonWrapper.cs.

Here is the caller graph for this function:

◆ InvokeVoidMethod()

void QuantConnect.Python.BasePythonWrapper< TInterface >.InvokeVoidMethod ( string  methodName,
params object[]  args 
)

Invokes the specified method with the specified arguments without returning a value

Parameters
methodNameThe name of the method
argsThe arguments to call the method with

Definition at line 174 of file BasePythonWrapper.cs.

◆ InvokeMethodAndEnumerate< T >()

IEnumerable<T> QuantConnect.Python.BasePythonWrapper< TInterface >.InvokeMethodAndEnumerate< T > ( string  methodName,
params object[]  args 
)

Invokes the specified method with the specified arguments and iterates over the returned values

Parameters
methodNameThe name of the method
argsThe arguments to call the method with
Returns
The returned valued converted to the given type

Definition at line 185 of file BasePythonWrapper.cs.

◆ InvokeMethodAndGetDictionary< TKey, TValue >()

Dictionary<TKey, TValue> QuantConnect.Python.BasePythonWrapper< TInterface >.InvokeMethodAndGetDictionary< TKey, TValue > ( string  methodName,
params object[]  args 
)

Invokes the specified method with the specified arguments and iterates over the returned values

Parameters
methodNameThe name of the method
argsThe arguments to call the method with
Returns
The returned valued converted to the given type

Definition at line 197 of file BasePythonWrapper.cs.

◆ InvokeMethodWithOutParameters< T >()

T QuantConnect.Python.BasePythonWrapper< TInterface >.InvokeMethodWithOutParameters< T > ( string  methodName,
Type[]  outParametersTypes,
out object[]  outParameters,
params object[]  args 
)

Invokes the specified method with the specified arguments and out parameters

Parameters
methodNameThe name of the method
outParametersTypesThe types of the out parameters
outParametersThe out parameters values
argsThe arguments to call the method with
Returns
The returned valued converted to the given type

Definition at line 211 of file BasePythonWrapper.cs.

◆ InvokeMethodAndWrapResult< T >()

T QuantConnect.Python.BasePythonWrapper< TInterface >.InvokeMethodAndWrapResult< T > ( string  methodName,
Func< PyObject, T >  wrapResult,
params object[]  args 
)

Invokes the specified method with the specified arguments and wraps the result by calling the given function if the result is not a C# object

Parameters
methodNameThe name of the method
wrapResultMethod that wraps a Python object in the corresponding Python Wrapper
argsThe arguments to call the method with
Returns
The returned value wrapped using the given method if the result is not a C# object

Definition at line 225 of file BasePythonWrapper.cs.

◆ Equals() [1/2]

virtual bool QuantConnect.Python.BasePythonWrapper< TInterface >.Equals ( BasePythonWrapper< TInterface >  other)
virtual

Determines whether the specified instance wraps the same Python object reference as this instance, which would indicate that they are equal.

Parameters
otherThe other object to compare this with
Returns
True if both instances are equal, that is if both wrap the same Python object reference

Definition at line 294 of file BasePythonWrapper.cs.

Here is the caller graph for this function:

◆ Equals() [2/2]

override bool QuantConnect.Python.BasePythonWrapper< TInterface >.Equals ( object  obj)

Determines whether the specified object is an instance of BasePythonWrapper<TInterface> and wraps the same Python object reference as this instance, which would indicate that they are equal.

Parameters
objThe other object to compare this with
Returns
True if both instances are equal, that is if both wrap the same Python object reference

Definition at line 305 of file BasePythonWrapper.cs.

◆ GetHashCode()

override int QuantConnect.Python.BasePythonWrapper< TInterface >.GetHashCode ( )

Gets the hash code for the current instance

Returns
The hash code of the current instance

Definition at line 314 of file BasePythonWrapper.cs.

Member Data Documentation

◆ Instance

PyObject QuantConnect.Python.BasePythonWrapper< TInterface >.Instance => _instance
protected

Gets the underlying python instance

Definition at line 37 of file BasePythonWrapper.cs.


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