title: Serializing to XML via DataContract: custom output?
body: <p>I have a custom Fraction class, which I'm using throughout my whole project. It's simple, it consists of a single constructor, accepts two ints and stores them. I'd like to use the DataContractSerializer to serialize my objects used in my project, some of which include Fractions as fields. Ideally, I'd like to be able to serialize such objects like this:</p>
  
  <pre><code>&lt;Object&gt;
      ...
      &lt;Frac&gt;1/2&lt;/Frac&gt; // "1/2" would get converted back into a Fraction on deserialization.
      ...
  &lt;/Object&gt;
  </code></pre>
  
  <p>As opposed to this:</p>
  
  <pre><code>&lt;Object&gt;
      ...
      &lt;Frac&gt;
          &lt;Numerator&gt;1&lt;/Numerator&gt;
          &lt;Denominator&gt;2&lt;/Denominator&gt;
      &lt;/Frac&gt;
      ...
  &lt;/Object&gt;
  </code></pre>
  
  <p><em>Is there any way to do this using DataContracts?</em></p>
  
  <p>I'd like to do this because I plan on making the XML files user-editable (I'm using them as input for a music game, and they act as notecharts, essentially), and want to keep the notation as terse as possible for the end user, so they won't need to deal with as many walls of text.</p>
  
  <p><strong>EDIT</strong>: I should also note that I currently have my Fraction class as immutable (all fields are <code>readonly</code>), so being able to change the state of an existing Fraction wouldn't be possible. Returning a new Fraction object would be OK, though.</p>