I'm building a cross-platform application for Windows, OSX, iOS, Windows Mobile, Android and web in ASP.NET. For every client I use C# (I'm using Xamarin). Everything in single VS solution. My core code (domain) is in Class Library (portable), so it can be used in every UI (Client).
I want to use IoC container in that project and here is my problem: I don't know whether IoC that I'll pick, will work in every Client. I know that for example Ninject doesn't work in portable Class Library - there is Ninject.Portable for such project. That made me thinking, it's possible that IoC which I will pick will not work in one of my Clients which will be bad.
So, my question is: Which IoC containers can be used in portable class libraries and in every client (UI) made in Visual Studio 2015?
I was interested in Simple Injector, but now I have these doubts.
Most Xamarin. Forms applications, will use Dependency Injection, and hence an IoC (Inversion of Control) container. In this post, we will be looking at the performance of these frameworks, in 3 scenarios. Registering types into the container. Resolving a simple type.
The most valuable benefit of using an IoC container is that you can have a configuration switch in one place which lets you change between, say, test mode and production mode. For example, suppose you have two versions of your database access classes...
I have written a small abstraction layer on IoC containers and plugins for containers that work with Xamarin. They are available on NuGet:
https://www.nuget.org/packages?q=xlabs.ioc
Tested containers (unit tests are in GitHub):
Matt Whetton has written an excellent guide on how to use them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With