We are trying to implement IoC from xamarin.android in a MvvmCross project. Cannot figure out how to get type specified in IoC container into Setup.cs, of the android project (not ViewModel)
Setup.cs
protected override IMvxIoCProvider CreateIocProvider()
{
_provider = base.CreateIocProvider();
return _provider;
}
protected override void InitializeFirstChance()
{
_provider.RegisterSingleton<INotificationService>(new NotificationService(ApplicationContext));
_provider.RegisterType<ITaskFilter>(() => new FilterView());
base.InitializeFirstChance();
}
In the Android MvxActivity, we have two possible ways but the first one isn't working and the second one breaks SOLID principles we trying to follow.
[MvvmCross.Platform.IoC.MvxInject]
public ITaskFilter TaskFilter { get; set; }
And
public TasksView()
{
var taskFilter = MvvmCross.Platform.IoC.MvxSimpleIoCContainer.Instance.Resolve<ITaskFilter>();
}
TaskFilter.Initialize(this);
I know there is likely to be more required for this question to be answered, please ask for that which you need. Thanks