There are 2 ways to consume OData: Atom/XML and JSON. As we've already seen, we can fairly easily extract, interpret and visualize our data from an OData service using JSON, as we have a library at our disposal that allows us to address the data as an object and query it.
If however we want to dynamically interpret OData services, things become a little trickier. Imagine that we want to develop a tool that allows flexible interaction with any OData service (like XOData in Chrome but in a virtual environment), that would imply that we can interpret the OData service's metadata, identify its entitysets, associated attributes and navigational links. Additionally, the metadata of an OData service is only available in XML..
Luckily we're not working in a vacuum and stuff already exists:
- Microsoft is on top of this with the Windows Communication Foundation ( https://msdn.microsoft.com/en-us/library/ms731082(v=vs.110).aspx ), which as a framework allows to flexibly address an OData service. It basically generates classes that you can leverage in C# to address entitysets as objects.
- An alternative is also available that is not generative: Simple.OData.Client ( http://vagif.bloggingabout.net/category/simple-odata-client/) and looks pretty promising..
But sadly, none of these beautiful libraries interact well with Unity & MonoDevelop. After loads & loads of cryptic compilation errors I basically just gave up trying to make it work. My best grasp of the issue here comes down to Unity/MonoDevelop not supporting much over .Net 3.5, while both libraries require at least 4.0.
My best attempt so far involved getting a nice Visual Studio project running that interprets the OData service, setting that up as a DLL that I then reused in another project. Easy enough, C# and .Net is just too easy. When I try including the same DLL for reuse in my Unity scripts however, the strange and dubious compilation errors appear. In short: BLOCKED.
That is slightly annoying and puts me back a little. It would have made life a lot easier if some of the work to interpret the metadata of any OData service was readily available, but no such luck. As an alternative, I'm back to parsing the XML and interpreting it as such.
For now, let's not focus on the overall "I want to interpret any OData service's metadata and render it as visual objects that I can drill into to visualize and analyse its content", let's just try to visualize it (baby steps!) ;-)