I have my own class of fractions, which I use throughout my project. It is simple, it consists of one constructor, takes two ints and saves them. I would like to use the DataContractSerializer to serialize my objects used in my project, some of which include Fractions fields. Ideally, I would like to serialize such objects as follows:
<Object>
...
<Frac>1/2</Frac> // "1/2" would get converted back into a Fraction on deserialization.
...
</Object>
In contrast to this:
<Object>
...
<Frac>
<Numerator>1</Numerator>
<Denominator>2</Denominator>
</Frac>
...
</Object>
Is there a way to do this using DataContracts?
, XML ( , ) , .
. , ( readonly), , Fraction .