Code Monkey home page Code Monkey logo

Comments (29)

LordMike avatar LordMike commented on August 13, 2024

It could be possible. Do you have any examples of other projects that have done this?
I'm thinking along the lines of if there is a RestSharp replacement readily available (or a PCL-compatible JSON parser).

That'd really be all we needed, as the network layer (actually GETting and POSTing stuff) is easy.

from tmdblib.

DynamicDave avatar DynamicDave commented on August 13, 2024

Dear Michael,

That's also what I tought... the network layer and the json parser are the only two part of the project that are not PCL compatible.

For the network layer you van use the Microsoft ASP.NET Web API client libraries combined with Newtonsoft Json.NET. Both are PCL compatible. Just installing the Web API client libraries (http://www.nuget.org/packages/Microsoft.AspNet.WebApi.Client/5.1.2) should by sufficient.

Some (simple) example code:
public class JsonClient where T : class
{
public T GetResult(string url)
{
var client = new HttpClient();
client.BaseAddress = new Uri("https://api.themoviedb.org/3/");
var response = client.GetAsync(url).Result;
string result = response.Content.ReadAsStringAsync().Result;
var rootobject = JsonConvert.DeserializeObject(result);
return rootobject;
}
}

public class MovieHandler
{
private static JsonClient client = new JsonClient();
public static Movie GetMovie(int id)
{
string url = string.Format("movie/{1}?api_key={0}", "#apikey#", id.ToString());
return client.GetResult(url);
}
}

from tmdblib.

DynamicDave avatar DynamicDave commented on August 13, 2024

Update: with Update 2 of Visual Studio 2013 you don't even need the Microsoft ASP.NET Web API client libraries. Newtonsoft Json.NET is enough.

from tmdblib.

LordMike avatar LordMike commented on August 13, 2024

Begun work in a seperate branch: pcl-version

from tmdblib.

LordMike avatar LordMike commented on August 13, 2024

@DynamicDave, could you test the branch pcl-version at commit dd15f98?

There are 2 tests that fail in this version, which don't fail in the master-version. But that shouldn't affect most use cases, so you should be able to use the PCL version already. Try it out and let me know if I've done something wrong.

I wasn't able to target PCL directly, but I upgraded to .NET 4.5 and was able to install the Web API Nuget package. It should cover as PCL, but might not.

from tmdblib.

Vannevelj avatar Vannevelj commented on August 13, 2024

Has there been any development on this? I'd very much like to have a PCL library of just the models so I can refer to them cross-project.

from tmdblib.

 avatar commented on August 13, 2024

👍 really need it!

from tmdblib.

LordMike avatar LordMike commented on August 13, 2024

@bbougot, I'm guessing it's for Mobile apps?

But if @Naliath agrees, perhaps we should move to MS-HttpClient and Newtonsoft.Json for v. 1.0.0?

from tmdblib.

 avatar commented on August 13, 2024

@LordMike Yup that's it! I'd like to use it into a Universal App project

from tmdblib.

Naliath avatar Naliath commented on August 13, 2024

This seems the way most rest sharp users are moving in any case (checked some issues involving this exact request from the ResetSharp repo)

from tmdblib.

DynamicDave avatar DynamicDave commented on August 13, 2024

I haven't been working on the PCL version for a while. Perhaps I can start working on the project again soon. But I have a lot of other work to do, so I'm lacking time.

from tmdblib.

LordMike avatar LordMike commented on August 13, 2024

The issue is just that. Time.
But now that we're merging versions (async -> master), perhaps we can do
the next step: Remove Restsharp.

I've forgotten everything I know about PCL. Is it a new target, or just a
convention when no non-PCL libraries are referenced?
Is it a new Nuget target, how will it affect other users of Nuget builds,
etc.. ? :P

Mvh.
Michael

On Tue, Sep 22, 2015 at 8:58 AM, Dave Jonker [email protected]
wrote:

I haven't been working on the PCL version for a while. Perhaps I can start
working on the project again soon. But I have a lot of other work to do, so
I'm lacking time.


Reply to this email directly or view it on GitHub
#44 (comment).

from tmdblib.

DynamicDave avatar DynamicDave commented on August 13, 2024

A PCL is a Portable Class Library. MS says: "The Portable Class Library project enables you to write and build managed assemblies that work on more than one .NET Framework platform. You can create classes that contain code you wish to share across many projects, such as shared business logic, and then reference those classes from different types of projects."

It's basically a subset of the .Net framework. So not all functionality is available. You can reference it, for example, from a winforms project but also from a Xamarin, WinPhone or Xbox project.

from tmdblib.

Naliath avatar Naliath commented on August 13, 2024

Seems it's a separate project type. So it would result in:

  • Create new project
  • Move all files over
  • Replace all unsupported dependencies

Preferable we can just replace the project file so we can retain the file history on the code files

Time is always an issue but this should be relatively easy to implement since we would just be replacing something that is already centralized. If we wrap the new lib in a thin wrapper it should be OK.

https://msdn.microsoft.com/en-us/library/vstudio/gg597391(v=vs.110).aspx
https://msdn.microsoft.com/en-us/library/vstudio/gg597391(v=vs.110).aspx#create_pcl

from tmdblib.

DynamicDave avatar DynamicDave commented on August 13, 2024

Dear Naliath, that's why I've made the separate branch
https://github.com/DynamicDave/TMDbLib

from tmdblib.

Naliath avatar Naliath commented on August 13, 2024

@DynamicDave yea perfect just saying there have been quite a few changes since you created the branch so we will have to do some merging :)

from tmdblib.

DynamicDave avatar DynamicDave commented on August 13, 2024

I know :-)

from tmdblib.

LordMike avatar LordMike commented on August 13, 2024

I imagine it would be as simple as declaring that "henceforth we be PCL", and then fixing all compile errors. :P

Maybe we should move to HttpClient(Newtonsoft in a seperate move though.

EDIT: Oh shoot. It's actually a seperate template... Meh. Just kill the old project, add a new with the same name, let git handle the diffs. Story kept :)

from tmdblib.

 avatar commented on August 13, 2024

@LordMike There's a portable version of RestSharp here :
https://github.com/FubarDevelopment/restsharp.portable
It can be useful for the PCL version of TMDBLib

from tmdblib.

LordMike avatar LordMike commented on August 13, 2024

Hmm, also published to Nuget: https://www.nuget.org/packages/FubarCoder.RestSharp.Portable/

I wonder if it's a drop-in replacement.

from tmdblib.

LordMike avatar LordMike commented on August 13, 2024

@DynamicDave we've just worked up a RestSharp replacemnet using HttpClient. Could you try this out?

Note that the library is now completely async, so you might have to change a few calls. :)

from tmdblib.

Naliath avatar Naliath commented on August 13, 2024

Make a quick PCL version, right now just put a new project next to the old one. I didn't make any namespace changes so should be able to just dump the new over the old after changing the project name and project namespace

@LordMike You care to take a look? Just ran the test app and that looks fine, didn't check in more detail. Just felt like hacking something together :)

from tmdblib.

LordMike avatar LordMike commented on August 13, 2024

Thought of doing the same. I'll try looking tomorrow. I imagine, for history's sake, we'll do a commit that simply changes the project type, instead of moving files :P.

-----Original Message-----
From: "Thomas Vriens" [email protected]
Sent: ‎27-‎01-‎2016 00:03
To: "LordMike/TMDbLib" [email protected]
Cc: "Michael Bisbjerg" [email protected]
Subject: Re: [TMDbLib] Portable Class Library (#44)

Make a quick PCL version, right now just put a new project next to the old one. I didn't make any namespace changes so should be able to just dump the new over the old after changing the project name and project namespace
@LordMike You care to take a look? Just ran the test app and that looks fine, didn't check in more detail. Just felt like hacking something together :)

Reply to this email directly or view it on GitHub.

from tmdblib.

LordMike avatar LordMike commented on August 13, 2024

I'm trying it out now. It seems very promising - running tests take time though.

from tmdblib.

LordMike avatar LordMike commented on August 13, 2024

@Naliath looks really good. I've created issues for the two problems I found running tests. You already took care of the Description thing - but the HttpValueCollection I might rewrite to something smaller.

from tmdblib.

Naliath avatar Naliath commented on August 13, 2024

Good job, yea the HttpValueCollection was just something I grabbed to get it to work and changed it only where there where issues getting things to build.

Besides the things you changed there where some issues with enums that I'm not sure I got a 100% replacement for. It seems PCL does not support the binding flags we used before to filter properties so it might be we are casting the net a bit wider than we were deserializing those props. I don't think it's an issue but still something to take note off.

from tmdblib.

LordMike avatar LordMike commented on August 13, 2024

Yea I noticed. I think I got it covered though by changing the enum type check, and then only taking a field who's value is equal to what were looking for.

It wont work for flag types though. By then again, neither did the previous code.

Reflection is severely limited in pcl. Also, inspecting the code behind the extension method for get fields revealed a "return null". Reading up on it, it seems that its a way of exposing platform specific functionality in pcl (the platform dll delivers the implementation)... It should work in all places, but I fear it may fail on some obscure platform.

Alternatively, we'll just replace the entire thing with a switch/return static strings.. :P

-----Original Message-----
From: "Thomas Vriens" [email protected]
Sent: ‎29-‎01-‎2016 10:18
To: "LordMike/TMDbLib" [email protected]
Cc: "Michael Bisbjerg" [email protected]
Subject: Re: [TMDbLib] Portable Class Library (#44)

Good job, yea the HttpValueCollection was just something I grabbed to get it to work and changed it only where there where issues getting things to build.
Besides the things you changed there where some issues with enums that I'm not sure I got a 100% replacement for. It seems PCL does not support the binding flags we used before to filter properties so it might be we are casting the net a bit wider than we were deserializing those props. I don't think it's an issue but still something to take note off.

Reply to this email directly or view it on GitHub.

from tmdblib.

Naliath avatar Naliath commented on August 13, 2024

yea for now it should be fine, if we ever run into issues we can still dumb it down

from tmdblib.

LordMike avatar LordMike commented on August 13, 2024

@DynamicDave Check out the 0.9.1.2-alpha. It's been migrated to work with Core apps. I'm unsure how this works with PCL (they're the same - now?)..

from tmdblib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.