Skip to content

Commit

Permalink
Added use of XmlReader class in Deserialize when passing a Stream. Th…
Browse files Browse the repository at this point in the history
…is avoids culture/locale specific issues with byte order mark (BOM) and encoding.
  • Loading branch information
ndodger committed Aug 26, 2020
1 parent 57d0aa9 commit 7fce8b9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions IbFlexReader/IbFlexReader.Xml/Deserializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ public static TOut Deserialize<TXml, TOut>(Stream content, out List<ErrorMessage
where TXml : XmlBase where TOut : class, new()
{
XmlSerializer serializer = new XmlSerializer(typeof(TXml));
var obj = (TXml)serializer.Deserialize(content);
errorObjects = new List<ErrorMessage>();
return new TOut().PopulateFrom(obj, errorObjects);
using (XmlReader reader = XmlReader.Create(content))
{
var obj = (TXml)serializer.Deserialize(reader);
errorObjects = new List<ErrorMessage>();
return new TOut().PopulateFrom(obj, errorObjects);
}
}

public static TOut Deserialize<TXml, TOut>(XmlReader content, out List<ErrorMessage> errorObjects)
Expand Down

0 comments on commit 7fce8b9

Please sign in to comment.