12-02-2016 09:10 AM
How can I implement similar deserialize functionality from XML to object as seen below on a .NET code snippet?
What I understand is that it is using the .NET System.XML.Serialization(4.0.0.0) GAC. If I select this GAC on a step using .NET adapter in TestStand2016 I can't see any classes. Is this correct way to do this?
Computer has .NET framework 4.6.1 SDK installed.
private Macro.Macro[] ReadMacroFile(string macroFileName)
{
FileStream fs = null;
try
{
var ser = new XmlSerializer(typeof(Macro.Macro[]));
fs = new FileStream((new FileInfo(macroFileName)).FullName, FileMode.Open);
var macroList = (Macro.Macro[])ser.Deserialize(fs);
return macroList;
}
finally
{
if (fs != null) fs.Close();
}
}
Best Regards
Petri
Solved! Go to Solution.
12-02-2016 09:29 AM
I'm not an expert on this but my guess is that you should just use System.Xml (4.x.x). Then you can select Serialization.XmlSerializer as your Root Class. In the .NET invocation you can choose XMLSerializer(type).Deserialize().
That should get you going.
Let me know if it helps,