From 9d2a1cc6b5c5bc6ba98447332b08cf41459ce298 Mon Sep 17 00:00:00 2001 From: Nick Randolph Date: Thu, 31 Aug 2023 23:28:55 +1000 Subject: [PATCH] chore: Tidy up api (cherry picked from commit a17b1bbfe669666ea2912459f801588e0fef4b08) --- .../MauiEmbedding.Mobile.csproj | 2 +- src/Uno.Extensions.Maui.UI/MauiEmbedding.cs | 42 +++---------------- 2 files changed, 6 insertions(+), 38 deletions(-) diff --git a/samples/MauiEmbedding/MauiEmbedding.Mobile/MauiEmbedding.Mobile.csproj b/samples/MauiEmbedding/MauiEmbedding.Mobile/MauiEmbedding.Mobile.csproj index b34f083e07..7cf59e3ff2 100644 --- a/samples/MauiEmbedding/MauiEmbedding.Mobile/MauiEmbedding.Mobile.csproj +++ b/samples/MauiEmbedding/MauiEmbedding.Mobile/MauiEmbedding.Mobile.csproj @@ -39,7 +39,7 @@ - + diff --git a/src/Uno.Extensions.Maui.UI/MauiEmbedding.cs b/src/Uno.Extensions.Maui.UI/MauiEmbedding.cs index 41cb6effa3..fd71de410e 100644 --- a/src/Uno.Extensions.Maui.UI/MauiEmbedding.cs +++ b/src/Uno.Extensions.Maui.UI/MauiEmbedding.cs @@ -9,15 +9,6 @@ namespace Uno.Extensions.Maui; /// public static partial class MauiEmbedding { - /// - /// Registers Maui embedding in the Uno Platform app builder. - /// - /// The updated app builder. - /// The IHost builder. - /// Optional lambda to configure the Maui app builder. - public static IApplicationBuilder UseMauiEmbedding(this IApplicationBuilder builder, Action? configure = null) => - builder.UseMauiEmbedding(configure); - /// /// Registers Maui embedding in the Uno Platform app builder. /// @@ -26,21 +17,7 @@ public static IApplicationBuilder UseMauiEmbedding(this IApplicationBuilder buil /// Optional lambda to configure the Maui app builder. public static IApplicationBuilder UseMauiEmbedding(this IApplicationBuilder builder, Action? configure = null) where TApp : MauiApplication - { - builder.App.UseMauiEmbedding(builder.Window, configure); - return builder; - } - - /// - /// Registers Maui embedding in the Uno Platform app builder. - /// - /// The updated app builder. - /// The IHost builder. - /// The Uno app. - /// The Main Application Window. - /// Optional lambda to configure the Maui app builder. - public static IHostBuilder UseMauiEmbedding(this IHostBuilder builder, Microsoft.UI.Xaml.Application app, Microsoft.UI.Xaml.Window window, Action? configure = null) => - builder.UseMauiEmbedding(app, window, configure); + => builder.Configure(hostBuilder => hostBuilder.UseMauiEmbedding(builder.App, builder.Window, configure)); /// /// Registers Maui embedding in the Uno Platform app builder. @@ -63,16 +40,7 @@ public static IHostBuilder UseMauiEmbedding(this IHostBuilder builder, Mic /// The Uno app. /// The Main Application Window. /// Optional lambda to configure the Maui app builder. - public static Microsoft.UI.Xaml.Application UseMauiEmbedding(this Microsoft.UI.Xaml.Application app, Microsoft.UI.Xaml.Window window, Action? configure = null) => - app.UseMauiEmbedding(window, configure); - - /// - /// Registers Maui embedding with WinUI3 and WPF application builder. - /// - /// The Uno app. - /// The Main Application Window. - /// Optional lambda to configure the Maui app builder. - public static Microsoft.UI.Xaml.Application UseMauiEmbedding(this Microsoft.UI.Xaml.Application app, Microsoft.UI.Xaml.Window window, Action? configure = null) + public static MauiApp UseMauiEmbedding(this Microsoft.UI.Xaml.Application app, Microsoft.UI.Xaml.Window window, Action? configure = null) where TApp : MauiApplication { #if MAUI_EMBEDDING @@ -99,10 +67,10 @@ public static Microsoft.UI.Xaml.Application UseMauiEmbedding(this Microsof WindowStateManager.Default.OnActivated(window, args); }; #endif - - + return mauiApp; +#else + return default!; #endif - return app; } #if MAUI_EMBEDDING