Chapter 4. Different Cars, Same Engine
In this chapter, we will cover the following recipes:
- Sharing code between different platforms
- Using the dependency locator
- Adding a third-party Dependency Injection Container
- Architecture design with Model-View-ViewModel (MVVM) pattern
- Using the event messenger
- Adding localization
Introduction
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...