Inversion of Control (IoC) with Xamarin.Forms
The Inversion of Control (IoC) principle is very a useful technique when writing cross-platform applications.
So why should we use it?
Sharing 100% of the code would be great, but it is not entirely possible; we still require some implementation from platform-specific features (for example different platform services, hardware, cameras). A way to tackle this problem is via an IoC container. Using the IoC principle, we use an abstraction for the functionality in our shared code and pass an implementation of the abstraction into our shared code. Our IoC containers handle the instantiation of an object's dependency tree. We can register objects to their inherited interfaces and allow containers to pass registered objects as their abstracted interfaces all the way down the dependency tree (all the way to PCL).
So how do we benefit from this?
What if I needed view models to call methods to a native Bluetooth service in a PCL project?
To put it simply,...