Giter VIP home page Giter VIP logo

Comments (11)

deanebarker avatar deanebarker commented on June 7, 2024 1

Geez, took you long enough. I expect more responsiveness from you guys... :-)

from contentful.net.

deanebarker avatar deanebarker commented on June 7, 2024 1

When you come up with a more comprehensive event model, perhaps it would make sense to have events that overlap on those attributes, then steer people towards using the events for consistency and flexibility in the future. Clearly, you can't stop people from using OnDeserialized, but you can provide a better overall model and make it clear that it's "more canonical," supported, and resilient to future changes.

from contentful.net.

Roblinde avatar Roblinde commented on June 7, 2024

At the moment this isn't possible, but I understand that this would be convenient. I'm planning on adding some more serialization magic to the GetEntry-methods that would allow for this. Possibly you'd have to implement an interface, but I'm hoping that wouldn't be necessary, simply checking for the existence of a SystemProperties field via reflection should be enough.

from contentful.net.

Roblinde avatar Roblinde commented on June 7, 2024

Proposed solution (mostly so that I remember it myself...): Add the sys property as part of the fields structure before deserializing. That way any serialization attributes added to your POCO class would be respected and you could use custom serialization techniques like json converters or similar.

This would also make sure you don't have to add any custom interface or anything. Just a plain class.

from contentful.net.

Roblinde avatar Roblinde commented on June 7, 2024

This is now added in 0.5.2-alpha.

Documentation will be updated as soon as I get the time.

from contentful.net.

deanebarker avatar deanebarker commented on June 7, 2024

FYI -- I'm not seeing a 0.5.2-alpha out on Nuget. It doesn't show up as an update.

from contentful.net.

Roblinde avatar Roblinde commented on June 7, 2024

It's unlisted still, I think you need to manually install it through the package manager console. Let me know if it doesn't work.

from contentful.net.

deanebarker avatar deanebarker commented on June 7, 2024

Got it. I updated, and it works as expected.

To anyone else looking at this issue in the future: the SystemProperties property has to be named Sys. It's deserialized like any other field, so it's specifically matching on the Sys property name, not the fact that it is of type SystemProperties, which you might expect.

from contentful.net.

Roblinde avatar Roblinde commented on June 7, 2024

A small addition. The property could actually be named anything, but you would have to decorate it with an JsonProperty attribute to let the serialization engine know how to serialize.

Like this:

 public class Term {
      [JsonProperty("sys")]
      public SystemProperties NotSys { get; set; }
 }

Also not in the documentation yet 😞 . Will be adding a serialization / deserialization section sometime soonish.

from contentful.net.

deanebarker avatar deanebarker commented on June 7, 2024

There's always an interesting question of how to delineate the difference between (1) something that is specific to your API, and (2) something that is inherited from an "upstream" API (Newtonsoft JSON serialization, in this instance).

The OnDeserialized thing from #4 is another example -- from my reading, that's not your thing, that's core to the framework, and probably being called from the Newtonsoft library.

The trick is when people start to think you're just an overlay on top of a something upstream, then they start to depend on that upstream API's doc and capabilities, which gets tricky when you do things to change them, or even swap the upstream API out altogether.

from contentful.net.

Roblinde avatar Roblinde commented on June 7, 2024

Yeah, I agree, the serialization section would mostly be a pointer to the Json.Net documentations, but some "best practices" examples would be nice to have. The OnDeserialized attribute is actually a framework thing, but Json.Net implements it.

from contentful.net.

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.