Wednesday 15 August 2012

c# - Array deserialization only returning 1 element -


As the title says, when I deserialize the following file, I only get first (and always the first) element Is:

    

My code to deserialize:

  var list = (server connection) mSerializer. DIRECTORIZ (inputstream). Entries;   

More listings Then the number is 1. ServerConnections looks like this:

  public class ServerConnections {public ServerConnectionEntry [] entries {get; Set; }}   

There is no exception.

Edit: The problem occurs when I include my class which makes custom xml serialization IXmlSerializable). It does the following:

  void BigNumber :: ReadXml (System :: Xml :: XmlReader ^ reader) {reader- & gt; ReadStart Element (); XMLSeelizer ↑ Serializer = GCNE XML Serializer (CLI :: Array and Ltfinum; Byte; :: Typ Id); Cli :: Array & lt; Byte & gt; ^ Data = (cli :: arrays & lt; byte & gt; ^) serializer-> Deserialize (reader); Pin_ptr & lt; Unsigned four & gt; Ptr (and data [0]); BN_bin2bn (PTR, Data-> Length, Mnm); VoidNumber :: WriteXml (System :: Xml :: XmlWriter ^ Authors) {XmlSerializer ^ serializer = gcnew XmlSerializer (cli :: arrays & lt; byte & gt; :: typeid); Serializer-> Serialize (authors, tubettes ()); }   

After ReadXml, the data contains the correct data, the deserializer that prevents the entire list and does not read any additional element.

The same, it works fine to use the same code for you.

  Public class program {static zero main (string [] args) {XmlSerializer deserializer = New XmlSerializer (typef (server connection)); Var Reader = New Streamerder (@ "../../ Test.xml"); Var entries = (server connection) deserializer. Dairyialize (Reader); Reader.Close (); } Public Square ServerConnections {public ServerConnectionEntry entries] {get; Set; }} Public class ServerConnectionEntry {public string name {get; Set; } Public string host {get; Set; } Public string port {get; Set; } Public String Username {get; Set; } Public Binarcode AuthHash {get; Set; }} Public class binarycode {[XmlElement ("base64Binary")] public string code {get; Set; }}}    

No comments:

Post a Comment