Skip to content

PlatformAPI reference

Class BrowserStorage

Namespace: MicroEngine.Platform
Assembly: MicroEngine.Platform.dll
Guide: The platform host

Save slots in the page’s localStorage under “microengine/<game>/<slot>”: the default save medium in browsers. The browser’s file system is in memory and vanishes on reload; localStorage writes are synchronous and survive it. The page registers the “microengine” JavaScript module (its storage.get, storage.set and storage.remove functions) before the game starts; the browser host’s page does.

C#
public sealed class BrowserStorage : IStorage

Inheritance

object ← BrowserStorage

Implements

IStorage

Constructors

BrowserStorage(string)

The slots of the game gameId.

C#
public BrowserStorage(string gameId)

Parameters

gameId string

Exceptions

ArgumentException

gameId is null, empty or white space.

Properties

Location

“localStorage:” followed by the key prefix of this game’s slots.

C#
public string Location { get; }

Property Value

string

Methods

Delete(string)

Removes the slot; does nothing when it does not exist.

C#
public void Delete(string slot)

Parameters

slot string

Exists(string)

Whether the slot has data.

C#
public bool Exists(string slot)

Parameters

slot string

Returns

bool

Read(string)

The slot’s text, or null when it does not exist.

C#
public string? Read(string slot)

Parameters

slot string

Returns

string?

SetAside(string)

Moves unreadable data out of the slot, keeping a copy; best effort, never throws.

C#
public void SetAside(string slot)

Parameters

slot string

Write(string, string)

Replaces the slot atomically.

C#
public void Write(string slot, string text)

Parameters

slot string

text string