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:
- use different element names serialize attributes
- use collection hold
link
s. makes querying data hard in cases, believe give similar want.
sources
Comments
Post a Comment