Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which IoC continer to use in cross-platform (Xamarin) applications? [closed]

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.

like image 657
Todd Englewood Avatar asked Nov 15 '15 16:11

Todd Englewood


People also ask

What is IoC container Xamarin forms?

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.

Should I use IoC container?

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...


1 Answers

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):

  • Autofac
  • Ninject
  • SimpleInjector
  • TinyIOC
  • Unity

Matt Whetton has written an excellent guide on how to use them.

like image 80
SKall Avatar answered Oct 02 '22 21:10

SKall