title: Changing method Attributes at runtime
body: <p>I am trying to serialize objects into xml. I have setup up </p>
  
  <pre><code>public class Foo&lt;t&gt;
  {
      [XmlElement(ElementName ="test")]
      public &lt;t&gt; bar {
      get
      {
          var descriptor = TypeDescriptor.GetProperties(this.GetType())["bar"];
  
          var attrib =(XmlElementAttribute)descriptor.Attributes[typeof(XmlElementAttribute)];
          FieldInfo ElementName = attrib.GetType().GetProperty("ElementName")
          ElementName.SetValue(attrib, "success");
      }
      set{}
  }
  </code></pre>
  
  <p>I want to change XmlElement.ElementName at run time but so far have been unsucessfull.
  According to <a href="http://codinglight.blogspot.com/2008/10/changing-attribute-parameters-at.html" rel="nofollow noreferrer">this blog</a> you should be able to do it. Also this <a href="https://stackoverflow.com/questions/51269/change-attributes-parameter-at-runtime">SO post</a> indicates that I am on the right track. </p>
  
  <p>My Questions are <strong>Is what I want to do possible? How do I achieve this?</strong></p>
  
  <p><strong>EDIT:
  I want the xml node to be called 'Success' instead of 'test'</strong></p>