Skip to content

Commit

Permalink
feat: Adding mauiapp to uno services
Browse files Browse the repository at this point in the history
  • Loading branch information
nickrandolph committed Aug 31, 2023
1 parent 61cbe29 commit a8bda1d
Showing 1 changed file with 9 additions and 25 deletions.
34 changes: 9 additions & 25 deletions src/Uno.Extensions.Maui.UI/MauiEmbedding.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Maui.ApplicationModel;
using Microsoft.Maui.Hosting;
using Uno.Extensions.Hosting;

namespace Uno.Extensions.Maui;
Expand All @@ -9,15 +10,6 @@ namespace Uno.Extensions.Maui;
/// </summary>
public static partial class MauiEmbedding
{
/// <summary>
/// Registers Maui embedding in the Uno Platform app builder.
/// </summary>
/// <returns>The updated app builder.</returns>
/// <param name="builder">The IHost builder.</param>
/// <param name="configure">Optional lambda to configure the Maui app builder.</param>
public static IApplicationBuilder UseMauiEmbedding(this IApplicationBuilder builder, Action<MauiAppBuilder>? configure = null) =>
builder.UseMauiEmbedding<MauiApplication>(configure);

/// <summary>
/// Registers Maui embedding in the Uno Platform app builder.
/// </summary>
Expand Down Expand Up @@ -52,27 +44,20 @@ public static IHostBuilder UseMauiEmbedding(this IHostBuilder builder, Microsoft
/// <param name="configure">Optional lambda to configure the Maui app builder.</param>
public static IHostBuilder UseMauiEmbedding<TApp>(this IHostBuilder builder, Microsoft.UI.Xaml.Application app, Microsoft.UI.Xaml.Window window, Action<MauiAppBuilder>? configure = null)
where TApp : MauiApplication
{
app.UseMauiEmbedding<TApp>(window, configure);
return builder;
}
=> builder.ConfigureServices(services =>
{
// Expose the MauiApp to the Uno app via the IHost.Services
var mauiApp = app.UseMauiEmbedding<TApp>(window, configure);
services.AddSingleton(mauiApp);
});

/// <summary>
/// Registers Maui embedding with WinUI3 and WPF application builder.
/// </summary>
/// <param name="app">The Uno app.</param>
/// <param name="window">The Main Application Window.</param>
/// <param name="configure">Optional lambda to configure the Maui app builder.</param>
public static Microsoft.UI.Xaml.Application UseMauiEmbedding(this Microsoft.UI.Xaml.Application app, Microsoft.UI.Xaml.Window window, Action<MauiAppBuilder>? configure = null) =>
app.UseMauiEmbedding<MauiApplication>(window, configure);

/// <summary>
/// Registers Maui embedding with WinUI3 and WPF application builder.
/// </summary>
/// <param name="app">The Uno app.</param>
/// <param name="window">The Main Application Window.</param>
/// <param name="configure">Optional lambda to configure the Maui app builder.</param>
public static Microsoft.UI.Xaml.Application UseMauiEmbedding<TApp>(this Microsoft.UI.Xaml.Application app, Microsoft.UI.Xaml.Window window, Action<MauiAppBuilder>? configure = null)
public static MauiApp UseMauiEmbedding<TApp>(this Microsoft.UI.Xaml.Application app, Microsoft.UI.Xaml.Window window, Action<MauiAppBuilder>? configure = null)
where TApp : MauiApplication
{
#if MAUI_EMBEDDING
Expand Down Expand Up @@ -100,9 +85,8 @@ public static Microsoft.UI.Xaml.Application UseMauiEmbedding<TApp>(this Microsof
};
#endif


#endif
return app;
return mauiApp;
}

#if MAUI_EMBEDDING
Expand Down

0 comments on commit a8bda1d

Please sign in to comment.