Table of Contents

Class ThemeRegistryStateService

Namespace
SharpConsoleUI.Core
Assembly
SharpConsoleUI.dll

Per-ConsoleWindowSystem registry of available themes. Registration, lookup, and enumeration are scoped to the owning window system, so themes registered (including those contributed by a loaded plugin) never leak across instances. Pre-seeded with the built-in ModernGray theme plus the palette-generated seed catalog. Thread-safe.

public class ThemeRegistryStateService
Inheritance
ThemeRegistryStateService
Inherited Members
Extension Methods

Constructors

ThemeRegistryStateService()

Creates a registry pre-seeded with the built-in ModernGray theme and the seed catalog.

public ThemeRegistryStateService()

Properties

Count

Gets the number of registered themes.

public int Count { get; }

Property Value

int

DefaultThemeName

Gets or sets the name of the default theme to use when none is specified. Thread-safe.

public string DefaultThemeName { get; set; }

Property Value

string

Methods

GetAvailableThemeNames()

Gets all available theme names, sorted.

public IReadOnlyList<string> GetAvailableThemeNames()

Returns

IReadOnlyList<string>

GetAvailableThemes()

Gets all available themes with their information, sorted by name.

public IReadOnlyList<ThemeInfo> GetAvailableThemes()

Returns

IReadOnlyList<ThemeInfo>

GetDefaultTheme()

Gets a new instance of the configured default theme (DefaultThemeName).

public ITheme GetDefaultTheme()

Returns

ITheme

Exceptions

InvalidOperationException

Thrown if the default theme is not registered.

GetTheme(string)

Gets a new instance of the named theme, or null if not registered.

public ITheme? GetTheme(string name)

Parameters

name string

Returns

ITheme

GetThemeOrDefault(string, ITheme)

Gets the named theme, or defaultTheme if not registered.

public ITheme GetThemeOrDefault(string name, ITheme defaultTheme)

Parameters

name string
defaultTheme ITheme

Returns

ITheme

IsThemeRegistered(string)

Checks whether a theme with the given name is registered.

public bool IsThemeRegistered(string name)

Parameters

name string

Returns

bool

RegisterTheme(string, string, Func<ITheme>)

Registers a theme. If a theme with the same name already exists, it is replaced.

public void RegisterTheme(string name, string description, Func<ITheme> factory)

Parameters

name string
description string
factory Func<ITheme>

UnregisterTheme(string)

Unregisters a theme. Returns true if it was removed, false if not found.

public bool UnregisterTheme(string name)

Parameters

name string

Returns

bool