-
-
Notifications
You must be signed in to change notification settings - Fork 494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question - Serializing & Deserializing objects with inheritance #341
Comments
I went for the YamlStream approach but would be good to know if this is coming/possible with the simple approach. |
I believe the answer is "Tagging" -- see https://github.com/aaubry/YamlDotNet/wiki/Serialization.Deserializer#withtagmappingstring-type |
@Arakade is correct - I do inheritance in this way. |
Since this issue now has a really good answer I'm going to close it. Thanks @Arakade . |
I'm trying to understand the serialization & deserialization of objects a bit and how this works with inheritance.
If I have a class
Factory
:Where
ICar
specifies the following:Then I have different objects per car make such as
Ford
Which uses
Car
:This perfectly serializes as following:
Stupid questions inbound:
Ford
instead ofICar
?YamlStream
instead and parse it myself? This brings a lot of overhead that I would like to avoid (sample)NuGet Version
YamlDotNet
v5.0.1Full Repro
You can find a repro of what I want to achieve here
This currently throws an exception but I'm honestly not sure why:
The text was updated successfully, but these errors were encountered: