Deserializing of List Array appends instead of overwrite
XML / XSL
2
Posts
2
Posters
34
Views
1
Watching
-
Hi, I am using a list of a class. Serialization works fine, but Deserialization leads to creating new lists, which are appended to main list. I.e. if Deflists in AllKeyList contains 5 KeyDefinition Classes, after Deserialization there are 10. How can I force overriding? Thx adv for your help. What I'm doing:
FileStream fs = new FileStream(sFile, FileMode.Open); var x = new System.Xml.Serialization.XmlSerializer(Setup.GetType()); var settings = new XmlReaderSettings { CheckCharacters = false, }; try { Setup = (DataSettings)x.Deserialize(fs); Console.WriteLine("XML Read {0} erfolgreich", sFile);
Data structure:
public class KeyDefinition { public string Name { get; set; } public string KeyType { get; set; } public List KeyDef { get; set; } .... } public class AllKeyList { public List DefLists { get; set; } ... }
-
Hi, I am using a list of a class. Serialization works fine, but Deserialization leads to creating new lists, which are appended to main list. I.e. if Deflists in AllKeyList contains 5 KeyDefinition Classes, after Deserialization there are 10. How can I force overriding? Thx adv for your help. What I'm doing:
FileStream fs = new FileStream(sFile, FileMode.Open); var x = new System.Xml.Serialization.XmlSerializer(Setup.GetType()); var settings = new XmlReaderSettings { CheckCharacters = false, }; try { Setup = (DataSettings)x.Deserialize(fs); Console.WriteLine("XML Read {0} erfolgreich", sFile);
Data structure:
public class KeyDefinition { public string Name { get; set; } public string KeyType { get; set; } public List KeyDef { get; set; } .... } public class AllKeyList { public List DefLists { get; set; } ... }