Class CurrentPlugin
Represents the current plugin. Can only be used within HostFunctions.
public class CurrentPlugin
- Inheritance
-
CurrentPlugin
- Inherited Members
Properties
UserData
Returns the user data object that was passed in when a HostFunction was registered.
[Obsolete("Use GetUserData<T> instead.")]
public nint UserData { get; }
Property Value
Methods
AllocateBlock(long)
Allocate a memory block in the currently running plugin.
public long AllocateBlock(long length)
Parameters
length
long
Returns
BlockLength(long)
Get the length of an allocated block. NOTE: this should only be called from host functions.
public long BlockLength(long offset)
Parameters
offset
long
Returns
FreeBlock(long)
Frees a block of memory belonging to the current plugin.
public void FreeBlock(long offset)
Parameters
offset
long
GetCallHostContext<T>()
Get the current plugin call's associated host context data. Returns null if call was made without host context.
public T? GetCallHostContext<T>()
Returns
- T
Type Parameters
T
GetMemory()
Returns a offset to the memory of the currently running plugin. NOTE: this should only be called from host functions.
public long GetMemory()
Returns
GetUserData<T>()
Returns the user data object that was passed in when a HostFunction was registered.
public T? GetUserData<T>()
Returns
- T
Type Parameters
T
ReadBytes(long)
Returns a span of bytes for a given block.
public Span<byte> ReadBytes(long offset)
Parameters
offset
long
Returns
ReadString(long)
Reads a string from a memory block using UTF8.
public string ReadString(long offset)
Parameters
offset
long
Returns
ReadString(long, Encoding)
Reads a string form a memory block.
public string ReadString(long offset, Encoding encoding)
Parameters
Returns
WriteBytes(long, Span<byte>)
Writes a byte array into a block of memory.
public void WriteBytes(long offset, Span<byte> bytes)
Parameters
WriteBytes(Span<byte>)
Writes a byte array into a newly allocated block of memory.
public long WriteBytes(Span<byte> bytes)
Parameters
Returns
- long
Returns the offset of the allocated block
WriteString(string)
Writes a string into the current plugin memory using UTF-8 encoding and returns the offset of the block.
public long WriteString(string value)
Parameters
value
string
Returns
WriteString(string, Encoding)
Writes a string into the current plugin memory and returns the offset of the block.
public long WriteString(string value, Encoding encoding)