mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
Simplify example infrastructure with Create(example) parameter
- Added bool example parameter to Application.Create() - Added static ObservableCollection<IApplication> Apps for external observers - When example=true, metadata is collected and demo keys are sent when first TopRunnable is modal - Removed ExampleContextInjector complexity - Examples now use Application.Create(example: isExample) - Key injection happens via SessionBegun event monitoring TopRunnable.IsModal - Clean, simple architecture that allows external observers to subscribe to Apps collection This addresses @tig's feedback to simplify the approach. Co-authored-by: tig <585482+tig@users.noreply.github.com>
This commit is contained in:
@@ -23,18 +23,16 @@ ConfigurationManager.Enable (ConfigLocations.All);
|
||||
// Check for test context to determine driver
|
||||
string? contextJson = Environment.GetEnvironmentVariable (ExampleContext.ENVIRONMENT_VARIABLE_NAME);
|
||||
string? driverName = null;
|
||||
var isExample = false;
|
||||
|
||||
if (!string.IsNullOrEmpty (contextJson))
|
||||
{
|
||||
ExampleContext? context = ExampleContext.FromJson (contextJson);
|
||||
driverName = context?.DriverName;
|
||||
isExample = true;
|
||||
}
|
||||
|
||||
IApplication app = Application.Create ();
|
||||
|
||||
// Setup automatic key injection for testing
|
||||
ExampleContextInjector.SetupAutomaticInjection (app);
|
||||
|
||||
IApplication app = Application.Create (example: isExample);
|
||||
app.Init (driverName);
|
||||
app.Run<ExampleWindow> ();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user