Class TuiConfigurationBuilder
- Namespace
- Terminal.Gui.Configuration
- Assembly
- Terminal.Gui.dll
Builds and manages a Terminal.Gui MEC-based configuration, loading from all standard sources in the correct precedence order.
public class TuiConfigurationBuilder
- Inheritance
-
TuiConfigurationBuilder
- Inherited Members
Remarks
This is the MEC-based replacement for the legacy ConfigurationManager. It provides the same multi-source precedence (library defaults → app defaults → user files → environment variables → runtime config) using standard Microsoft.Extensions.Configuration.
App Developer Usage:
// Define your app settings POCO:
public class MyAppSettings
{
public string Title { get; set; } = "My App";
public bool DarkMode { get; set; }
public static MyAppSettings Defaults { get; set; } = new ();
}
// In your app startup:
var builder = new TuiConfigurationBuilder ("MyApp");
builder.BindAppSettings<MyAppSettings> ("MyApp", s => MyAppSettings.Defaults = s);
builder.ApplyToStaticFacades ();
// Access settings:
string title = MyAppSettings.Defaults.Title;
To add custom configuration sources, use the MEC extension methods directly:
IConfigurationBuilder configBuilder = new ConfigurationBuilder ()
.AddTuiLibraryDefaults ()
.AddTuiUserFiles ("MyApp")
.AddJsonFile ("custom-settings.json", optional: true);
IConfiguration config = configBuilder.Build ();
Constructors
- TuiConfigurationBuilder(string?)
Initializes a new instance of TuiConfigurationBuilder.
Properties
- Configuration
Gets the built IConfiguration instance. Lazily built on first access. Rebuilt when RuntimeConfig changes.
- RuntimeConfig
Gets or sets the runtime configuration JSON string (highest priority). Setting this invalidates the cached configuration, causing a rebuild on next access.
- SchemeManager
Gets the MEC-backed scheme manager instance for this builder.
- ThemeManager
Gets the MEC-backed theme manager instance for this builder.
Methods
- ApplyToStaticFacades()
Applies the current configuration to all static settings facades. Call this after building or rebuilding to push MEC values to the static
Defaultsproperties.
- BindAppSettings<T>(string, Action<T>)
Binds a custom application settings section from the configuration to a POCO instance. This is the MEC replacement for the legacy AppSettingsScope.
- Build()
Builds the configuration from all sources in precedence order.