add some convenience to enable single-line (new xxxApplication()).Start() paradigm

This commit is contained in:
Michael Becker 2021-01-09 22:16:25 -05:00
parent c275c25d0a
commit 83051d779f
No known key found for this signature in database
GPG Key ID: 98C333A81F18C22C

View File

@ -95,13 +95,19 @@ namespace MBS.Framework
{
}
public bool Initialized { get; private set; } = false;
[System.Diagnostics.DebuggerNonUserCode()]
public void Initialize()
{
if (Initialized)
return;
if (ShortName == null)
throw new ArgumentException("must specify a ShortName for the application");
InitializeInternal();
Initialized = true;
}
protected virtual int StartInternal()
@ -110,6 +116,11 @@ namespace MBS.Framework
}
public int Start()
{
if (Application.Instance == null)
Application.Instance = this;
Initialize();
int exitCode = StartInternal();
return exitCode;
}