c# - Having a class provide default XmlElementName -


i have set of classes trying serialize part of specification: http://open511.org/root.html

public class link {     public link()     {      }      public link(string url, string rel = "self")     {         url = url;         rel = rel;     }      [xmlattribute("rel")]     public string rel { get; set; }      [xmlattribute("href")]     public string url { get; set; } } 

and

public class service {     private link _servicetypeurl;      [xmlelement("link")]     public link servicetypeurl     {         { return _servicetypeurl; }         set         {             _servicetypeurl = value;             _servicetypeurl.rel = "service_type";         }     }      [xmlelement("link")]     public link url { get; set; }      [xmlarray("supported_versions")]     [xmlarrayitem("supported_version")]     public list<supportedversion> supportedversions { get; set; } } 

it won't let me have 2 properties same xmlelement. there way this?

i have loved have link class specify use element name "link"

it looks you're trying achieve isn't supported. alternatives are:

  1. use different element names serialize attributes
  2. use collection hold links. makes querying data hard in cases, believe give similar want.

sources


Comments

Popular posts from this blog

Error while updating a record in APEX screen -

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

ios - Xcode 5 "No such file or directory" -