To configure the dependency injection and initialize the resolver, we will create a bootstrapper. We will have one shared bootstrapper and other bootstrappers for each platform to meet their specific configurations. The reason that we need them to be platform-specific is that we will have different implementations of IPhotoImporter on iOS and Android. To create a bootstrapper, we take the following steps:
- Create a new class in the GalleryApp project and name it Bootstrapper.
- Add the following code to the new class:
using System.Linq;
using System.Reflection;
using Autofac;
using GalleryApp.ViewModels;
using Xamarin.Forms;
namespace GalleryApp
{
public class Bootstrapper
{
protected ContainerBuilder ContainerBuilder { get;
private set; }
public Bootstrapper()
{
Initialize();
FinishInitialization();
}
protected virtual void Initialize()
{
ContainerBuilder...