T
tinman31337
Dear list,
I have a collection of "notes" and want to deserialize them:
<notes>
<note>
<from>Gertie Garterbelt</from>
<to>El Douche</to>
<heading>hey</heading>
<body>don't forget me</body>
</notes>
As you might guess, I have a class "Note", made of
properties "From", "To", "Heading" and "Body".
Since I'm a friend of immutable data when I can get
it, I'd like to have those properties readonly. My domain
would support this, but deserialization clearly does not.
After all, how is the deserializer supposed to populate
readonly properties?
How does a professional handle this? Does .NET provide
a mechanism for setting properties readonly at runtime?
Or am I supposed to introduce a "_locked" flag into my
"Note" class that is checked by the setter of each property?
Kind regards
Tin
I have a collection of "notes" and want to deserialize them:
<notes>
<note>
<from>Gertie Garterbelt</from>
<to>El Douche</to>
<heading>hey</heading>
<body>don't forget me</body>
</notes>
As you might guess, I have a class "Note", made of
properties "From", "To", "Heading" and "Body".
Since I'm a friend of immutable data when I can get
it, I'd like to have those properties readonly. My domain
would support this, but deserialization clearly does not.
After all, how is the deserializer supposed to populate
readonly properties?
How does a professional handle this? Does .NET provide
a mechanism for setting properties readonly at runtime?
Or am I supposed to introduce a "_locked" flag into my
"Note" class that is checked by the setter of each property?
Kind regards
Tin