Skip to content
ConsoleMonster
Class

ThemeFile

ConsoleMonster.Styling

Namespace
ConsoleMonster.Styling
Assembly
ConsoleMonster
Modifiers
sealed

An immutable, validated theme document. JSON and data-dictionary imports share the same validation; loading never changes Terminal.Theme. PowerShell data-file syntax belongs to the PowerShell adapter.

Inheritance

  • object
  • ThemeFile

Remarks

Documents contain SchemaVersion (1), Name, optional BaseTheme and Tokens. Keys and token names are case-insensitive. BaseTheme must name a built-in preset; omitted tokens and style fields inherit from it. Without BaseTheme, omitted values use terminal defaults. An explicit null foreground/background clears inheritance. Exports contain every token, both colours, all fallback indices and decorations, without an inheritance dependency.

Usage

Explore 4 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Returned or exposed by 4

Methods

public static ThemeFile FromTheme(ITheme theme) #

Captures a theme for lossless export.

Parameters

theme ConsoleMonster.Styling.ITheme required
A built-in or custom theme. Custom implementations must be representable by ThemeStyle.

Returns

ThemeFile A validated snapshot independent of subsequent changes to a custom theme.

Exceptions

  • ArgumentException – A custom theme uses tier-specific decorations or colours that cannot be represented losslessly.
  • FormatException – A name, fallback index or decoration is invalid.
public static ThemeFile Import(IDictionary data) #

Validates data supplied by an adapter, such as a safely imported PowerShell hashtable.

Parameters

data System.Collections.IDictionary required
SchemaVersion (optional, defaults to 1), Name, optional BaseTheme, and Tokens.

Returns

ThemeFile A complete, validated document; the input dictionary is not retained or modified.

Exceptions

  • FormatException – An unknown key, token, preset or invalid value is present.
public static ThemeFile Load(string path) #

Reads a UTF-8 JSON theme file without changing global state.

Parameters

path string required
A file-system path. PSD1 must be read by the PowerShell adapter.

Returns

ThemeFile The validated document.

Exceptions

  • FormatException – The document is invalid.
public static ThemeFile Parse(string json) #

Parses JSON and validates every key, token, colour, fallback and decoration before returning.

Parameters

json string required
One JSON theme object. Comments, duplicate keys and trailing content are rejected.

Returns

ThemeFile A validated document.

Exceptions

  • FormatException – The JSON or theme data is invalid.
public void Save(string path) #

Writes this document as UTF-8 JSON without a byte order mark.

Parameters

path string required
The file to create or replace. The parent directory must already exist.
public IDictionary<string, object?> ToData() #

Returns a complete data-only dictionary suitable for an adapter's native serialization.

Returns

IDictionary<string, object?> A fresh dictionary; editing it cannot modify this document.
public string ToJson() #

Writes complete, indented JSON with every token and explicit fallback tier.

Returns

string The JSON document, ending in a newline.
public Theme ToTheme() #

Returns the immutable theme represented by this document without changing the active theme.

Returns

Theme A complete theme, including resolved inheritance.

Properties

public string Name { get; } #

The name used when the document is converted to a theme.