Skip to content

KernelAPI reference

Class CapabilityRegistry

Namespace: MicroEngine.Kernel
Assembly: MicroEngine.Kernel.dll
Guide: Modules and the frame schedule

Optional features something in the engine offers (a display that can change its mode, a touch screen, platform diagnostics), declared by whoever provides them and queried by type. A feature that is absent is simply not declared: callers ask with TryGet``1 instead of casting a platform or device to find out.

C#
public sealed class CapabilityRegistry

Inheritance

object ← CapabilityRegistry

Remarks

Read and written on the game’s thread; not thread-safe.

Constructors

CapabilityRegistry()

C#
public CapabilityRegistry()

Properties

Count

The number of declared capabilities.

C#
public int Count { get; }

Property Value

int

Methods

Add<T>(T)

Declares capability as the capability of type T.

C#
public void Add<T>(T capability) where T : class

Parameters

capability T

Type Parameters

T

Exceptions

ArgumentNullException

capability is null.

InvalidOperationException

A capability of type T is already declared; use Replace``1.

Has<T>()

Whether a capability is declared as T.

C#
public bool Has<T>() where T : class

Returns

bool

Type Parameters

T

Remove<T>()

Withdraws the capability declared as T; false when there was none.

C#
public bool Remove<T>() where T : class

Returns

bool

Type Parameters

T

Replace<T>(T)

Declares capability as the capability of type T, in place of the one declared before, if any.

C#
public void Replace<T>(T capability) where T : class

Parameters

capability T

Type Parameters

T

Exceptions

ArgumentNullException

capability is null.

TryGet<T>(out T?)

The capability declared as T, if there is one.

C#
public bool TryGet<T>(out T? capability) where T : class

Parameters

capability T?

Returns

bool

Type Parameters

T