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

喜夏-厌秋 提交于 2019-12-04 11:39:20

问题


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.


回答1:


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.




回答2:


There is an IoC container which works with Xamarin called SystemDot. It's on nuget.



来源:https://stackoverflow.com/questions/33722085/which-ioc-continer-to-use-in-cross-platform-xamarin-applications

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!