c# - DataContractSerializer on augmented list type -


I'm having trouble using DataContract s, where list wrapper with additional data Enhanced. The important part of XML is pasted here with the full link of XSD and document at the end of this post.

  & lt; Criteria & gt; & Lt; Kasauti & gt; & Lt; Name & gt; Common Name & lt; / Name & gt; & Lt; Price & gt; J350 & lt; / Pricing & gt; & Lt; Matches & gt; 3 & lt; / Matches & gt; & Lt; / Criterion & gt; & Lt; Kasauti & gt; & Lt; Name & gt; Designation & lt; / Name & gt; & Lt; Price & gt; J350 & lt; / Pricing & gt; & Lt; Matches & gt; 8 & lt; / Matches & gt; & Lt; / Criterion & gt; & Lt; Matches & gt; 2 & lt; / Matches & gt; & Lt ;! - Shows only results that match all criteria - & gt; & Lt; / Criteria & gt;   

I am now at this point:

  [Collection data contract (namespace = "The namespace")) Public Partial Category SearchResultsCriteria: List & lt; SearchResultsCriteriaInfo & gt; {[Datamember (name = "mail", order = 1)] // failed public effects {found; Set; Public content group {name, name = "criteria", namespace = "The namespace"}) Public partial class SearchResultsCriteriaInfo {[Database name (name = "name", order = 0)) Public string name {get; Set; } [DataMember (name = "value", order = 1)] public string value {get; Set; } [Datamember (name = "mail", order = 2)] public int match {received; Set; } // all other properties that can be shown in xml}   

The problem now, when I deserialize it using DataContractSerializer As expected in the list, all the values ​​for Fails on SearchResultsCriteria comes only through 0. What is missing me to deserialize the corresponding list correctly? I

Edit: The subject of the order!

When I came about the order of the elements when using the DataContract deserialization in XML, I can tell which problem can not be determined because the criteria can not be determined Above & lt; Criterion & gt; There is a variable number of elements. I was hoping that this would be the case that I could specify the criteria for match 1, and when only 1 criterion was specified, this would work because I I can live with the situation. However, this does not work when the class is specified with CollectionDataContract as I have specified above.

For a more specific reference, I am trying to write a service cover.

I'm not sure what exactly "enhanced list types" mean, but I will assume you List type members mean that the datamember is not classified as attributes, but still the need to round ahead and back during the sorting process.

Based on this understanding, what you need is IExtensibleDataObject and this will be a good starting point.

If I misunderstood your question ... sorry! Please explain what you mean.

Comments

Popular posts from this blog

qt - switch/case statement in C++ with a QString type -

python - sqlite3.OperationalError: near "REFERENCES": syntax error - foreign key creating -

Python's equivalent for Ruby's define_method? -