Move BootstrapperBase's autoLaunch to Start

This commit is contained in:
Antony Male 2014-05-21 12:22:13 +01:00
parent ac7c504d94
commit 0ba6061e59
4 changed files with 15 additions and 17 deletions

View File

@ -24,8 +24,7 @@ namespace Stylet
/// Create a new Bootstrapper, and specify whether to auto-start and auto-launhc
/// </summary>
/// <param name="autoStart">True to call this.Start() at the end of this constructor</param>
/// <param name="autoLaunch">True to call this.Launch at the end of this.Start()</param>
public Bootstrapper(bool autoStart, bool autoLaunch) : base(autoStart, autoLaunch) { }
public Bootstrapper(bool autoStart) : base(autoStart) { }
/// <summary>
/// IoC container. This is created after ConfigureIoC has been run.

View File

@ -18,28 +18,23 @@ namespace Stylet
/// <typeparam name="TRootViewModel">Type of the root ViewModel. This will be instantiated and displayed</typeparam>
public abstract class BootstrapperBase<TRootViewModel> where TRootViewModel : class
{
private bool autoLaunch;
/// <summary>
/// Reference to the current application
/// </summary>
protected Application Application { get; private set; }
/// <summary>
/// Create a new BootstrapperBase, which automatically starts and launches
/// Create a new BootstrapperBase, which automatically start
/// </summary>
public BootstrapperBase() : this(true, true) { }
public BootstrapperBase() : this(true) { }
/// <summary>
/// Create a new BootstrapperBase, and specify whether to auto-start and auto-launhc
/// Create a new BootstrapperBase, and specify whether to auto-start
/// </summary>
/// <param name="autoStart">True to call this.Start() at the end of this constructor</param>
/// <param name="autoLaunch">True to call this.Launch at the end of this.Start()</param>
[SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors", Justification = "Calling the virtual Start here really is the cleanest, most sensible thing to do")]
public BootstrapperBase(bool autoStart, bool autoLaunch)
[SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors", Justification = "We give the user the option to not call the virtual method, and call it themselves, if they want/need to")]
public BootstrapperBase(bool autoStart)
{
this.autoLaunch = autoLaunch;
this.Application = Application.Current;
// Allows for unit testing
@ -59,7 +54,8 @@ namespace Stylet
/// <summary>
/// Called from the constructor, this does everything necessary to start the application
/// </summary>
protected virtual void Start()
/// <param name="autoLaunch">True to automatically launch the main window</param>
protected virtual void Start(bool autoLaunch = true)
{
// Stitch the IoC shell to us
IoC.GetInstance = this.GetInstance;
@ -79,7 +75,7 @@ namespace Stylet
View.ViewManager = IoC.Get<IViewManager>();
if (this.autoLaunch && !Execute.InDesignMode)
if (autoLaunch && !Execute.InDesignMode)
this.Launch();
}

View File

@ -21,7 +21,7 @@ namespace StyletUnitTests
private IViewManager viewManager;
private IWindowManager windowManager;
public MyBootstrapperBase(IViewManager viewManager, IWindowManager windowManager) : base(false, false)
public MyBootstrapperBase(IViewManager viewManager, IWindowManager windowManager) : base(false)
{
this.viewManager = viewManager;
this.windowManager = windowManager;
@ -75,7 +75,7 @@ namespace StyletUnitTests
base.Configure();
}
public new void Start()
public void Start()
{
base.Start();
}

View File

@ -21,7 +21,10 @@ namespace StyletUnitTests
private class MyBootstrapper<T> : Bootstrapper<T> where T : class
{
public MyBootstrapper() : base(true, false) { }
public MyBootstrapper() : base(false)
{
this.Start(false);
}
public IContainer Container
{