To configure dependency injection and initialize the Resolver, we need to create a bootstrapper. We will have one shared bootstrapper, as well as other bootstrappers for each platform that meet their specific configurations. The reason we need them to be platform-specific is that we will have different implementations of ILocationTrackingService on iOS and Android. To create a bootstrapper, do the following:
- Create a new class in the MeTracker project called Bootstrapper.
- Write the following code in the new class:
using Autofac; using MeTracker.Repositories; using MeTracker.ViewModels; using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; using Xamarin.Forms; namespace MeTracker {
public class Bootstrapper
{
protected ContainerBuilder ContainerBuilder { get; private
set; }
public Bootstrapper()
{
Initialize();
FinishInitialization();
...