Skip to main content

IMoBroPersistenceManager

The IMoBroPersistenceManager provides a simple and efficient way for plugins to serialize and persist arbitrary objects to disk.
Data is stored in the plugin's data directory and remains accessible between plugin starts.

note

Objects managed by this service are persisted in JSON format and therefore must be serializable using the System.Text.Json.JsonSerializer.

Functions

Put<T>(string, T)

Stores data with the specified key.

Type Parameters

NameDescription
TThe type of data to store

Parameters

NameTypeDescription
keystringThe unique key to identify the data
dataTThe data to be stored

Get<T>(string): T?

Retrieves the data associated with the specified key.

Type Parameters

NameDescription
TThe type of data to retrieve

Parameters

NameTypeDescription
keystringThe key to identify the stored data

Returns

  • The stored data of type T if it exists.
  • default(T) if the key is not found or the object is not of type T.

Remove(string): bool

Removes the data associated with the specified key.

Parameters

NameTypeDescription
keystringThe key to identify the data to remove

Returns

  • true: If the data was successfully removed.
  • false: If the key does not exist.

Exists(string): bool

Checks whether data associated with the specified key exists in the store.

Parameters

NameTypeDescription
keystringThe key to check for existence

Returns

  • true: If data with the specified key exists.
  • false: If data with the specified key does not exist.

Clear()

Deletes all persisted data.