PlatformAPI reference
Class HostBuilder
Namespace: MicroEngine.Hosting
Assembly: MicroEngine.Hosting.dll
Guide: Composing a game for every platform
The composition of one host, configured once by the game’s Configure entry point and reused by every host
that runs it: the desktop launcher (Program.cs), the browser page, the Android and iOS apps and tests. The
host fills its defaults first (its platforms, where content files are, where saves go), then calls the game’s
Configure, which may replace any of them and adds what the game needs (the game itself, platforms of its own,
engine services). Nothing here is process-wide: two hosts in one process (an editor, parallel tests) never share a
composition.
public sealed class HostBuilderInheritance
Examples
public sealed class MainGame : Game{ public static void Configure(HostBuilder host) => host.UseGame(() => new MainGame()); ...}Remarks
The engine’s modules keep their own parts in Services; the game façade adds methods to choose the game
and change the platform catalog and request (UseGame, Platforms, ConfigureRequest in
MicroEngine.Core).
Constructors
HostBuilder(HostEnvironment, LaunchRequest)
A composition for one launch of request in environment.
public HostBuilder(HostEnvironment environment, LaunchRequest request)Parameters
environment HostEnvironment
request LaunchRequest
Exceptions
An argument is null.
Properties
Content
Where the game’s content files come from when the game names no folder of its own; null (the default) for the
Content folder next to the program. The desktop host sets a macOS bundle’s resources, the Android app the
folder it unpacked its assets to, the iOS app its bundle’s folder. Any source works: a folder
(FolderContentSource), a zip archive (ZipContentSource) or files a host lists and opens itself
(ListedContentSource).
public IContentSource? Content { get; set; }Property Value
EngineConfiguration
Changes applied to every engine this host composes, after the game’s own Game.Configure.
public IReadOnlyList<Action<EngineBuilder>> EngineConfiguration { get; }Property Value
IReadOnlyList<Action<EngineBuilder>>
Environment
What the host knows about its process: its kind, developer variables and output.
public HostEnvironment Environment { get; }Property Value
Kind
The kind of host composing (Kind).
public HostKind Kind { get; }Property Value
Request
What this launch asked for (script, captures, platform, time…).
public LaunchRequest Request { get; }Property Value
Services
The composition’s own parts, by type: the engine’s modules keep theirs here; a game may add its own.
public ServiceRegistry Services { get; }Property Value
Storage
The save medium for a game id, for games that ask the composition for it; null (the default) for the platform’s default (files in the user’s data folder, the page’s localStorage in browsers).
public Func<string, IStorage>? Storage { get; set; }Property Value
Methods
ConfigureEngine(Action<EngineBuilder>)
Adds a change to every engine this host composes (services, systems, settings), applied in the order added.
public HostBuilder ConfigureEngine(Action<EngineBuilder> configure)Parameters
configure Action<EngineBuilder>
Returns
This builder, for chaining.