Created
November 6, 2022 13:48
-
-
Save schovan/3ba38aaf210a492c2f52a74a46a4d4de to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// To learn more about WinUI, the WinUI project structure, | |
// and more about our project templates, see: http://aka.ms/winui-project-info. | |
namespace MauiApp1.Platforms.Windows; | |
/// <summary> | |
/// Provides application-specific behavior to supplement the default Application class. | |
/// </summary> | |
public partial class App | |
{ | |
private IServiceProvider _serviceProvider; | |
/// <summary> | |
/// Initializes the singleton application object. This is the first line of authored code | |
/// executed, and as such is the logical equivalent of main() or WinMain(). | |
/// </summary> | |
public App() | |
{ | |
this.InitializeComponent(); | |
Initialize(); | |
} | |
protected override MauiApp CreateMauiApp() | |
{ | |
var app = MauiProgram.CreateMauiApp(); | |
_serviceProvider = app.Services; | |
return app; | |
} | |
protected override object GetInstance(Type service, string key) | |
{ | |
return _serviceProvider.GetService(service); | |
} | |
protected override IEnumerable<object> GetAllInstances(Type service) | |
{ | |
return _serviceProvider.GetServices(service); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment