CVB.Net 15.1
Loading...
Searching...
No Matches

CVB PyScript object (variant-like Python object). More...

Inherits INativeHandle.

Public Member Functions

void Dispose ()
 IDisposable implementation.
 
PythonObject GetAttribute (string name)
 Gets an attribute as a PythonObject.
 
PythonObject Run ()
 Runs this object as a callable without arguments.
 
PythonObject Run (PythonObject args)
 Runs this object as a callable with a tuple of arguments.
 
PythonObject GetElement (int index)
 Gets a tuple/list element by index.
 
void SetElement (int index, PythonObject value)
 Sets a tuple/list element by index.
 
As< T > ()
 Interprets the object as a type.
 

Static Public Member Functions

static PythonObject Create< T > (T value)
 Creates a PythonObject from the given value. Supports strings, CVB handles, primitives, and CVB value-type structs.
 
static PythonObject MakeVoidTuple (int size)
 Creates a tuple object pre-sized with None entries.
 
static PythonObject MakeTuple (params object[] args)
 Creates a tuple object populated with the given arguments.
 
static PythonObject CreateNone ()
 Creates a Python 'None' object.
 

Properties

int ElementCount [get]
 Gets the element count (valid for list/tuple only).
 
IntPtr Handle [get]
 Native handle of the object.
 
bool IsDisposed [get]
 Gets if the native handle has been disposed.
 

Events

NativeHandleEventDelegate ObjectDisposing
 Raised when this object is about to be disposed via the IDisposable.Dispose method.
 
- Events inherited from INativeHandle
NativeHandleEventDelegate ObjectDisposing
 Raised when this object is about to be disposed via the IDisposable.Dispose method.
 

Detailed Description

CVB PyScript object (variant-like Python object).

Member Function Documentation

◆ As< T >()

T As< T > ( )

Interprets the object as a type.

Returns
The requested type if contained within the object.

◆ Create< T >()

static PythonObject Create< T > ( T value)
static

Creates a PythonObject from the given value. Supports strings, CVB handles, primitives, and CVB value-type structs.

Parameters
valueThe object to put into the python object.
Template Parameters
TThe type of the object to put into the python object.
Returns
The newly created python object.

◆ CreateNone()

static PythonObject CreateNone ( )
static

Creates a Python 'None' object.

Returns
None python object.

◆ GetElement()

PythonObject GetElement ( int index)

Gets a tuple/list element by index.

Parameters
indexIndex of the object to get.

◆ MakeTuple()

static PythonObject MakeTuple ( params object[] args)
static

Creates a tuple object populated with the given arguments.

Returns
Newly created tuple with the given args .

See SetElement(int, PythonObject), GetElement(int) and ElementCount for handling the items in the tuple.

Exceptions
ArgumentNullExceptionWhen args is null.

◆ MakeVoidTuple()

static PythonObject MakeVoidTuple ( int size)
static

Creates a tuple object pre-sized with None entries.

Parameters
sizeSize of the tuple to create.
Returns
Empty tuple with the given size .

See SetElement(int, PythonObject), GetElement(int) and ElementCount for handling the items in the tuple.

Exceptions
ArgumentOutOfRangeExceptionWhen size smaller 0.

◆ Run() [1/2]

PythonObject Run ( )

Runs this object as a callable without arguments.

Returns
The result of the call as a PythonObject (may be "None").

◆ Run() [2/2]

Runs this object as a callable with a tuple of arguments.

Parameters
argsArguments for the call. Must be a tuple.
Returns
The result of the call as a PythonObject (may be "None").

◆ SetElement()

void SetElement ( int index,
PythonObject value )

Sets a tuple/list element by index.

Parameters
indexIndex to set.
valueObject to set at the given index .

Event Documentation

◆ ObjectDisposing

NativeHandleEventDelegate ObjectDisposing

Raised when this object is about to be disposed via the IDisposable.Dispose method.

This event is raised right before this object is disposed. The dispose itself cannot be canceled.