In this chapter, we will learn the different approaches, Shared Projects and Portable Class Libraries (PCL), to share code across all platforms.
DependencyService
is the out-of-the-box service locator from Xamarin.Forms and we will learn how to use it to resolve implementation classes for our interfaces in runtime.
Using a service locator is a solution to register the implementation classes you need to use for your abstracted interfaces in the application. In this chapter, we will explore Xamarin.Forms' built-in DependencyService
to map interfaces to implementation classes.
Moving forward, we will explore aspect oriented programming (AOP), which is accomplished using Dependency Injection. With Dependency Injection, the class is given its dependencies automatically via a constructor with all required parameters. The Dependency Injection Container is responsible for resolving the dependencies needed; we will use Ninject to see how we can apply Dependency Injection in our solution...