ThemeFile
ConsoleMonster.Styling
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
- Method ThemeFile.FromTheme
- Method ThemeFile.Import
- Method ThemeFile.Load
- Method ThemeFile.Parse
Methods
public static ThemeFile FromTheme(ITheme theme) #Captures a theme for lossless export.
Parameters
- theme ConsoleMonster.Styling.ITheme
- A built-in or custom theme. Custom implementations must be representable by ThemeStyle.
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
- SchemaVersion (optional, defaults to 1), Name, optional BaseTheme, and Tokens.
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
- A file-system path. PSD1 must be read by the PowerShell adapter.
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
- One JSON theme object. Comments, duplicate keys and trailing content are rejected.
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
- 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.
Inherited Methods
Properties
public string Name { get; } #The name used when the document is converted to a theme.