Implementing the IoC container and modules
Just like our last projects, we are going to set up another IoC container using Autofac. Let's first add the Autofac nuget packages to all projects in the solution. We can then copy the IoC
folder from the Stocklist.Portable
project in Chapter 5, Building a Stocklist Application. Make sure you include both the IoC.cs
and IModule.cs
files.
Now let's hop over to the native projects, add the Modules
folder in the iOS and Android projects, and implement IOSModule.cs
and DroidModule.cs
:
public class IOSModule : IModule { #region Public Methods public void Register(ContainerBuilder builder) { builder.RegisterType<SQLiteSetup>().As<ISQLiteSetup>().SingleInstance(); builder.RegisterType<SQLitePlatformIOS>().As<ISQLitePlatform>().SingleInstance(); } #endregion }
and the DroidModule,
public class DroidModule : IModule { #region Public Methods...