mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-15 12:45:01 +00:00
fix: Fixed a bug where AbstractGenericXmlConverter was not reading out of empty elements
This commit is contained in:
@@ -111,39 +111,24 @@ namespace ICD.Common.Utils.Xml
|
||||
if (reader.NodeType != XmlNodeType.Element && !reader.ReadToNextElement())
|
||||
throw new FormatException();
|
||||
|
||||
T output = default(T);
|
||||
bool instantiated = false;
|
||||
bool isEmpty = reader.IsEmptyElement;
|
||||
T output = Instantiate();
|
||||
|
||||
// Read the root attributes
|
||||
while (reader.MoveToNextAttribute())
|
||||
ReadAttribute(reader, output);
|
||||
|
||||
// Read out of the root element
|
||||
if (!reader.Read())
|
||||
throw new FormatException();
|
||||
|
||||
// There were no child elements
|
||||
if (isEmpty)
|
||||
return output;
|
||||
|
||||
// Read through child elements
|
||||
while (true)
|
||||
{
|
||||
if (!instantiated)
|
||||
{
|
||||
switch (reader.NodeType)
|
||||
{
|
||||
case XmlNodeType.Element:
|
||||
if (reader.IsEmptyElement)
|
||||
return default(T);
|
||||
|
||||
output = Instantiate();
|
||||
instantiated = true;
|
||||
|
||||
// Read the root attributes
|
||||
while (reader.MoveToNextAttribute())
|
||||
ReadAttribute(reader, output);
|
||||
|
||||
// Read out of the root element
|
||||
if (!reader.Read())
|
||||
throw new FormatException();
|
||||
continue;
|
||||
|
||||
default:
|
||||
// Keep reading until we reach the root element.
|
||||
if (!reader.Read())
|
||||
throw new FormatException();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
switch (reader.NodeType)
|
||||
{
|
||||
case XmlNodeType.Element:
|
||||
|
||||
Reference in New Issue
Block a user