In this section, we will create a Bootstrapper class. We will use this to set up the common configurations that we need in the startup phase of the app. Usually, there is one part of the bootstrapper for each target platform and one that is shared for all platforms. In this project, we only need the shared part. Let's set this up:
- In the Weather project, create a new class called Bootstrapper.
- Add a new public static method called Init.
- Create a new ContainerBuilder and register the types to container.
- Create a Container by using the Build method of ContainerBuilder. Create a variable called container that contains the instance of Container.
- Use the Initialize method on Resolver and pass the container variable as an argument.
- The Bootstrapper class should now look as follows:
using Autofac;
using TinyNavigationHelper.Forms;
using Weather.Services;
using Weather.ViewModels;
using Weather.Views;
using Xamarin.Forms;
...