Class ThemeRegistry
- Namespace
- SharpConsoleUI.Themes
- Assembly
- SharpConsoleUI.dll
Central registry for discovering and accessing available themes by name. Provides thread-safe theme registration, lookup, and management.
public static class ThemeRegistry
- Inheritance
-
ThemeRegistry
- Inherited Members
Properties
Count
Gets the number of registered themes.
public static int Count { get; }
Property Value
DefaultThemeName
Gets or sets the name of the default theme to use when none is specified. Thread-safe property with synchronized access.
public static string DefaultThemeName { get; set; }
Property Value
Methods
GetAvailableThemeNames()
Gets a list of all available theme names.
public static IReadOnlyList<string> GetAvailableThemeNames()
Returns
- IReadOnlyList<string>
A read-only list of theme names.
GetAvailableThemes()
Gets a list of all available themes with their information.
public static IReadOnlyList<ThemeInfo> GetAvailableThemes()
Returns
- IReadOnlyList<ThemeInfo>
A read-only list of theme information records.
GetDefaultTheme()
Gets the default theme as configured by DefaultThemeName.
public static ITheme GetDefaultTheme()
Returns
- ITheme
A new instance of the default theme.
Exceptions
- InvalidOperationException
Thrown if the default theme is not registered.
GetTheme(string)
Gets a theme by name.
public static ITheme? GetTheme(string name)
Parameters
namestringThe name of the theme to retrieve.
Returns
- ITheme
A new instance of the theme, or null if not found.
GetThemeOrDefault(string, ITheme)
Gets a theme by name, or returns a default theme if not found.
public static ITheme GetThemeOrDefault(string name, ITheme defaultTheme)
Parameters
namestringThe name of the theme to retrieve.
defaultThemeIThemeThe theme to return if the named theme is not found.
Returns
- ITheme
A new instance of the named theme, or the default theme if not found.
IsThemeRegistered(string)
Checks if a theme with the specified name is registered.
public static bool IsThemeRegistered(string name)
Parameters
namestringThe name of the theme to check.
Returns
- bool
True if the theme is registered, false otherwise.
RegisterTheme(string, string, Func<ITheme>)
Registers a theme in the registry. If a theme with the same name already exists, it will be replaced.
public static void RegisterTheme(string name, string description, Func<ITheme> factory)
Parameters
namestringThe unique name for the theme.
descriptionstringA description of the theme.
factoryFunc<ITheme>A factory method that creates new instances of the theme.
Exceptions
- ArgumentNullException
Thrown if name, description, or factory is null.
- ArgumentException
Thrown if name is empty or whitespace.
UnregisterTheme(string)
Unregisters a theme from the registry.
public static bool UnregisterTheme(string name)
Parameters
namestringThe name of the theme to unregister.
Returns
- bool
True if the theme was removed, false if it was not found.