Closed vb2ae closed 1 year ago
What happens if I want to register platform specific services into the IoC container when it is structured like this?
As long as you use the same instance of the simple container in the platforms it works properly
Here is an example
In maui app.xaml.cs
private static SimpleContainer _container;
public static SimpleContainer container
{
get
{
if (_container == null)
{
_container = new SimpleContainer();
_container.Instance(_container);
}
return _container;
}
}
protected override void Configure()
{
container.PerRequest<IDataService, DataService>();
container.PerRequest<MainViewModel>();
container.PerRequest<MainView>();
}
In windows app.xaml.cs
protected override void Configure()
{
ClientNoSqlDB.Samples.Maui.App.container.PerRequest<IPlatformSpecific, WindowsInstance>();
}
In android.app.xaml
protected override void Configure()
{
ClientNoSqlDB.Samples.Maui.App.container.PerRequest<IPlatformSpecific, AndroidSpecific>();
}
Update the maui implementation to do dependency injection in Caliburn Micro MauiApplication instead of platform specific CaliburnApplication
Related to #831