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

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -

java - How to specify maven bin in eclipse maven plugin? -