public static IMauiContext MakeApplicationScope(this IMauiContext mauiContext, NativeApplication platformApplication) { var scopedContext = new MauiContext(mauiContext.Services); scopedContext.AddSpecific(platformApplication); scopedContext.InitializeScopedServices(); return scopedContext; }
public static IMauiContext MakeWindowScope(this IMauiContext mauiContext, NativeWindow platformWindow, out IServiceScope scope) { scope = mauiContext.Services.CreateScope(); #if ANDROID var scopedContext = new MauiContext(scope.ServiceProvider, platformWindow); #else var scopedContext = new MauiContext(scope.ServiceProvider); #endif scopedContext.AddWeakSpecific(platformWindow); #if ANDROID scopedContext.AddSpecific(new NavigationRootManager(scopedContext)); #endif #if WINDOWS scopedContext.AddSpecific(new NavigationRootManager(platformWindow)); #endif return(scopedContext); }