fractal
fractal

Reputation: 1679

Servicestack monotouch DLL built using PCL

I'm migrating a solution to MVVMCross but the ServiceStack client libraries are difficult to work with.

How can I build ServiceStack client DLL into PCL library for use in Xamarin Studio so it's multi platform?

There is nothing of note here unless I missed it: https://github.com/ServiceStack

Upvotes: 4

Views: 427

Answers (2)

Telemat
Telemat

Reputation: 398

I ran into some issues related to .net (e.g. Timer class is missing in .net 4.5). So I just created a different library and then created a wrapper for the timer class. This is one way of doing it. Having your http code in a separate library would make the project easier to maintain.

One step further would be to use mvvmcross dependency injection to instantiate the class you have created in the other library. That way, even if you are instantiating non-PCL code it does not matter, the thing just works. You will have to declare all your interfaces in a separate PCL library though.

Upvotes: 1

Derek Beattie
Derek Beattie

Reputation: 9478

You could clone the ServiceStack project, make a PCL project, link the files, build, and see what is missing. I'm sure there is a reason there isn't a PCL already but if you happen to get it going, make a pull request.

Since you're using MvvmCross another option is to make a plugin for your API then reference the ServiceStack libs in the platform specific projects.

You could also use the MvvmCross RestClient and make the same calls the ServiceStack client would make.

edit: A 4th alternative is to use the new HttpClient's. The one from Xamarin and the other from MS (if you're targeting Win). Add in PortableRest and you'd be able to keep most of the code in a portable. I say most because you might have to abstract out the HttpClient. I've used this approach a few times and it works pretty well. There is a fork of PortableRest that added file uploads.

Upvotes: 3

Related Questions