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.
public sealed class BrowserStorage : IStorageInheritance
Implements
Constructors
BrowserStorage(string)
The slots of the game gameId.
public BrowserStorage(string gameId)Parameters
gameId string
Exceptions
gameId is null, empty or white space.
Properties
Location
“localStorage:” followed by the key prefix of this game’s slots.
public string Location { get; }Property Value
Methods
Delete(string)
Removes the slot; does nothing when it does not exist.
public void Delete(string slot)Parameters
slot string
Exists(string)
Whether the slot has data.
public bool Exists(string slot)Parameters
slot string
Returns
Read(string)
The slot’s text, or null when it does not exist.
public string? Read(string slot)Parameters
slot string
Returns
SetAside(string)
Moves unreadable data out of the slot, keeping a copy; best effort, never throws.
public void SetAside(string slot)Parameters
slot string
Write(string, string)
Replaces the slot atomically.
public void Write(string slot, string text)Parameters
slot string
text string