title: C#: Best way to have XML element name from generic type name
body: <p>I want to create a xml for a generic class. One of the properties has the generic type. For this property I don't want to use the property name as its XML element name, but the name of the generic type. </p>
  
  <p>The class looks like this:</p>
  
  <pre class="lang-cs prettyprint-override"><code>[XmlRoot("Entity")]
  public class StoreItem&lt;TEntity&gt;
      where TEntity : class, new()
  {
      /// &lt;summary&gt;
      /// Gets and sets the status of the entity when storing.
      /// &lt;/summary&gt;
      [XmlAttribute]
      public System.Data.Services.Client.EntityStates Status { get; set; }
  
      /// &lt;summary&gt;
      /// Gets and sets the entity to be stored.
      /// &lt;/summary&gt;
      public TEntity Entity { get; set; }
  }
  </code></pre>
  
  <p>When serializing a store item of kind <code>StoreItem&lt;SewageArea&gt;</code> the XML should contain something like:</p>
  
  <pre><code>&lt;Entity Status="Deleted"&gt;
      &lt;SewageArea ...&gt;
         ...
      &lt;/SewageArea&gt;
  &lt;Entity&gt;
  </code></pre>
  
  <p>The requirement is, that the <code>SewageArea</code> in the above example should be serialized in the "normal" way. Another important thing is that if its possible the code should be prepared to automatically serializes new added properties at the <code>StoreItem</code>class.</p>