Skip to content

Commit

Permalink
Merge pull request #1230 from dvorn/BootstrapperOnInitialized
Browse files Browse the repository at this point in the history
Bootstrapper.OnInitialized added.
  • Loading branch information
brianlagunas committed Nov 2, 2017
2 parents a017f5b + 97395bf commit 3a8ef43
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Source/Wpf/Prism.Wpf.Tests/BootstrapperFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,22 @@ public void ConfigureDefaultRegionBehaviorsShouldAddRegionLifetimeBehavior()

Assert.IsTrue(bootstrapper.DefaultRegionBehaviorTypes.ContainsKey(RegionMemberLifetimeBehavior.BehaviorKey));
}

[TestMethod]
public void OnInitializedShouldRunLast()
{
var bootstrapper = new DefaultBootstrapper();

bootstrapper.Run();

Assert.IsTrue(bootstrapper.ExtraInitialization);
}
}

internal class DefaultBootstrapper : Bootstrapper
{
public IRegionBehaviorFactory DefaultRegionBehaviorTypes;
public bool ExtraInitialization;

public ILoggerFacade BaseLogger
{
Expand Down Expand Up @@ -293,7 +304,12 @@ public void CallConfigureViewModelLocator()

public override void Run(bool runWithDefaultConfiguration)
{
throw new NotImplementedException();
Assert.IsFalse(this.ExtraInitialization);
}

protected override void OnInitialized()
{
this.ExtraInitialization = true;
}

protected override DependencyObject CreateShell()
Expand Down
9 changes: 9 additions & 0 deletions Source/Wpf/Prism.Wpf/Bootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ protected virtual ILoggerFacade CreateLogger()
public void Run()
{
this.Run(true);

this.OnInitialized();
}

/// <summary>
Expand Down Expand Up @@ -192,5 +194,12 @@ protected virtual void InitializeShell()
/// Configures the LocatorProvider for the <see cref="Microsoft.Practices.ServiceLocation.ServiceLocator" />.
/// </summary>
protected abstract void ConfigureServiceLocator();

/// <summary>
/// Contains actions that should occur last.
/// </summary>
protected virtual void OnInitialized()
{
}
}
}

0 comments on commit 3a8ef43

Please sign in to comment.