title: Serializing objects in a list with RestSharp
body: <p>I have a problem serializing my POCO objects to XML using RestSharp. My POCO object looks like this:</p>
  
  <p><strong>Person</strong></p>
  
  <pre><code>[SerializeAs(Name = "person")]
  public class Person
  {
      [SerializeAs(Name = "author-id")]
      public int? AuthorId { get; set; }
  
      [SerializeAs(Name = "background")]
      public string Background { get; set; }
  
      [SerializeAs(Name = "first-name")]
      public string FirstName { get; set; }
  
      [SerializeAs(Name = "last-name")]
      public string LastName { get; set; }
  
      [SerializeAs(Name = "id")]
      public int? Id { get; set; }
  
      [SerializeAs(Name = "company-name")]
      public string CompanyName { get; set; }
  
      [SerializeAs(Name = "title")]
      public string Title { get; set; }
  
      [SerializeAs(Name = "contact-data")]
      public ContactData ContactData { get; set; }
  
      [SerializeAs(Name = "tags")]
      public List&lt;tag&gt; Tags { get; set; }
  }
  </code></pre>
  
  <p><strong>ContactData</strong></p>
  
  <pre><code>public class ContactData
  {
      [SerializeAs(Name = "addresses")]
      public List&lt;object&gt; Addresses { get; set; }
  
      [SerializeAs(Name = "phone-numbers")]
      public List&lt;object&gt; PhoneNumbers { get; set; }
  
      [SerializeAs(Name = "email-adresses")]
      public List&lt;object&gt; EmailAddresses { get; set; }
  
      [SerializeAs(Name = "web-addresses")]
      public List&lt;object&gt; WebAddresses { get; set; }
  }
  </code></pre>
  
  <p><strong>EmailAddress</strong></p>
  
  <pre><code>[SerializeAs(Name = "email-address")]
  public class EmailAddress
  {
      [SerializeAs(Name = "address")]
      public string Address { get; set; }
  
      [SerializeAs(Name = "id")]
      public int? Id { get; set; }
  
      [SerializeAs(Name = "location")]
      public string Location { get; set; }
  }
  </code></pre>
  
  <p>This gives me the following XML when serialized:</p>
  
  <pre><code>&lt;person&gt;
      &lt;first-name&gt;my firstname&lt;/first-name&gt; 
      &lt;contact-data&gt;
          &lt;email-adresses&gt;
              &lt;EmailAddress&gt;
                  &lt;address&gt;my@email.com&lt;/address&gt; 
                  &lt;location&gt;Work&lt;/location&gt; 
               &lt;/EmailAddress&gt;
          &lt;/email-adresses&gt;
      &lt;/contact-data&gt;
      &lt;tags&gt;
          &lt;tag&gt;
              &lt;name&gt;Nyhedsbrev&lt;/name&gt; 
          &lt;/tag&gt;
      &lt;/tags&gt;
  &lt;/person&gt;
  </code></pre>
  
  <p>As you might notice, the EmailAddress <code>SerializeAs</code> is ignored. I think this may be because it's in a <code>List</code> since the <code>Person</code> object is correctly serialized as <code>&lt;person&gt;</code></p>
  
  <p>I need my POCO objects within a List (or some collection) to be serialized using the annotation instead of the class name itself.</p>
  
  <p>Has anyone found a workaround on this?</p>