diff --git a/src/Maui/Prism.Maui/Navigation/PrismWindowManager.cs b/src/Maui/Prism.Maui/Navigation/PrismWindowManager.cs index 8c2390cf8b..7b95b7a770 100644 --- a/src/Maui/Prism.Maui/Navigation/PrismWindowManager.cs +++ b/src/Maui/Prism.Maui/Navigation/PrismWindowManager.cs @@ -20,7 +20,7 @@ public Window CreateWindow(Application app, IActivationState activationState) else if (app.Windows.OfType().Any()) return _initialWindow = app.Windows.OfType().First(); - activationState.Context.Services.GetRequiredService().OnAppStarted(); + activationState.Context.Services.GetRequiredService().OnCreateWindow(); return _initialWindow ?? throw new InvalidNavigationException("Expected Navigation Failed. No Root Window has been created."); } diff --git a/src/Maui/Prism.Maui/PrismAppBuilder.cs b/src/Maui/Prism.Maui/PrismAppBuilder.cs index 8e0b33bfec..1dcb36ddc9 100644 --- a/src/Maui/Prism.Maui/PrismAppBuilder.cs +++ b/src/Maui/Prism.Maui/PrismAppBuilder.cs @@ -21,7 +21,7 @@ public sealed class PrismAppBuilder private List> _registrations { get; } private List> _initializations { get; } private IContainerProvider _container { get; } - private Func _onAppStarted; + private Func _createWindow; private Action _configureAdapters; private Action _configureBehaviors; @@ -181,14 +181,14 @@ internal void OnInitialized() } } - internal void OnAppStarted() + internal void OnCreateWindow() { - if (_onAppStarted is null) - throw new ArgumentException("You must call OnAppStart on the PrismAppBuilder."); + if (_createWindow is null) + throw new ArgumentException("You must call CreateWindow on the PrismAppBuilder."); // Ensure that this is executed before we navigate. OnInitialized(); - var onStart = _onAppStarted(_container, _container.Resolve()); + var onStart = _createWindow(_container, _container.Resolve()); onStart.Wait(); } @@ -196,11 +196,11 @@ internal void OnAppStarted() /// When the is started and the native platform calls /// this delegate will be invoked to do your initial Navigation. /// - /// The Navigation Delegate. + /// The Navigation Delegate. /// The . - public PrismAppBuilder CreateWindow(Func onAppStarted) + public PrismAppBuilder CreateWindow(Func createWindow) { - _onAppStarted = onAppStarted; + _createWindow = createWindow; return this; } diff --git a/src/Maui/Prism.Maui/PrismAppBuilderExtensions.cs b/src/Maui/Prism.Maui/PrismAppBuilderExtensions.cs index edaa5be09e..ce59d27eeb 100644 --- a/src/Maui/Prism.Maui/PrismAppBuilderExtensions.cs +++ b/src/Maui/Prism.Maui/PrismAppBuilderExtensions.cs @@ -6,10 +6,20 @@ namespace Prism; +/// +/// Common extensions and overloads for the +/// public static class PrismAppBuilderExtensions { private static bool s_didRegisterModules = false; + /// + /// Configures the to use Prism with a callback for the + /// + /// The . + /// The instance of the Prism should use. + /// A delegate callback for the + /// The . public static MauiAppBuilder UsePrism(this MauiAppBuilder builder, IContainerExtension containerExtension, Action configurePrism) { var prismBuilder = new PrismAppBuilder(containerExtension, builder); @@ -17,6 +27,12 @@ public static MauiAppBuilder UsePrism(this MauiAppBuilder builder, IContainerExt return builder; } + /// + /// Provides a Delegate to invoke when the App is initialized. + /// + /// The . + /// The delegate to invoke. + /// The . public static PrismAppBuilder OnInitialized(this PrismAppBuilder builder, Action action) { return builder.OnInitialized(_ => action()); @@ -45,9 +61,24 @@ public static PrismAppBuilder ConfigureModuleCatalog(this PrismAppBuilder builde }); } + /// + /// When the is started and the native platform calls + /// this delegate will be invoked to do your initial Navigation. + /// + /// The . + /// The initial Navigation Uri. + /// The . public static PrismAppBuilder CreateWindow(this PrismAppBuilder builder, string uri) => builder.CreateWindow(navigation => navigation.NavigateAsync(uri)); + /// + /// When the is started and the native platform calls + /// this delegate will be invoked to do your initial Navigation. + /// + /// The . + /// The intial Navigation Uri. + /// A delegate callback if the navigation fails. + /// The . public static PrismAppBuilder CreateWindow(this PrismAppBuilder builder, string uri, Action onError) => builder.CreateWindow(async navigation => { @@ -56,30 +87,78 @@ public static PrismAppBuilder CreateWindow(this PrismAppBuilder builder, string onError(result.Exception); }); - public static PrismAppBuilder CreateWindow(this PrismAppBuilder builder, Func CreateWindowed) => - builder.CreateWindow((c, n) => CreateWindowed(c, n)); + /// + /// When the is started and the native platform calls + /// this delegate will be invoked to do your initial Navigation. + /// + /// The . + /// The Navigation Delegate. + /// The . + public static PrismAppBuilder CreateWindow(this PrismAppBuilder builder, Func createWindow) => + builder.CreateWindow((c, n) => createWindow(c, n)); - public static PrismAppBuilder CreateWindow(this PrismAppBuilder builder, Func CreateWindowed) => - builder.CreateWindow((_, n) => CreateWindowed(n)); + /// + /// When the is started and the native platform calls + /// this delegate will be invoked to do your initial Navigation. + /// + /// The . + /// The Navigation Delegate. + /// The . + public static PrismAppBuilder CreateWindow(this PrismAppBuilder builder, Func createWindow) => + builder.CreateWindow((_, n) => createWindow(n)); - public static PrismAppBuilder CreateWindow(this PrismAppBuilder builder, Func CreateWindowed) => - builder.CreateWindow(n => CreateWindowed(n).NavigateAsync()); + /// + /// When the is started and the native platform calls + /// this delegate will be invoked to do your initial Navigation. + /// + /// The . + /// The Navigation Delegate. + /// The . + public static PrismAppBuilder CreateWindow(this PrismAppBuilder builder, Func createWindow) => + builder.CreateWindow(n => createWindow(n).NavigateAsync()); + + /// + /// When the is started and the native platform calls + /// this delegate will be invoked to do your initial Navigation. + /// + /// The . + /// The Navigation Delegate. + /// The . + public static PrismAppBuilder CreateWindow(this PrismAppBuilder builder, Func createWindow) => + builder.CreateWindow((c, n) => createWindow(c, n).NavigateAsync()); - public static PrismAppBuilder CreateWindow(this PrismAppBuilder builder, Func CreateWindowed) => - builder.CreateWindow((c, n) => CreateWindowed(c, n).NavigateAsync()); + /// + /// Provides a configuration delegate to add services to the + /// + /// The . + /// Configuration Delegate + /// The . public static PrismAppBuilder ConfigureServices(this PrismAppBuilder builder, Action configureServices) { configureServices(builder.MauiBuilder.Services); return builder; } + /// + /// Provides a delegate to configure Logging within the Maui application + /// + /// The . + /// + /// The . public static PrismAppBuilder ConfigureLogging(this PrismAppBuilder builder, Action configureLogging) { configureLogging(builder.MauiBuilder.Logging); return builder; } + /// + /// Provides a configuration Delegate to the to set the + /// DefaultViewTypeToViewModelTypeResolver. + /// + /// The . + /// The Configuration Delegate for the Default ViewType to ViewModelType Resolver. + /// The . public static PrismAppBuilder ConfigureViewTypeToViewModelTypeResolver(this PrismAppBuilder builder, Func viewModelTypeResolver) { ViewModelLocationProvider.SetDefaultViewTypeToViewModelTypeResolver(viewModelTypeResolver);