From e9063682efd2cdf01a4f9948d8cb940edcd70211 Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Wed, 17 Oct 2018 17:13:18 -0400 Subject: [PATCH] refactor: Tidying --- ICD.Common.Utils/Xml/IcdXmlReader.cs | 33 +++++++++++++++++----------- ICD.Common.Utils/Xml/XmlUtils.cs | 5 ++--- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/ICD.Common.Utils/Xml/IcdXmlReader.cs b/ICD.Common.Utils/Xml/IcdXmlReader.cs index 7274d5e..18e2af1 100644 --- a/ICD.Common.Utils/Xml/IcdXmlReader.cs +++ b/ICD.Common.Utils/Xml/IcdXmlReader.cs @@ -138,19 +138,6 @@ namespace ICD.Common.Utils.Xml } } - public string ReadElementContentAsString() - { - try - { - return m_Reader.ReadElementContentAsString(); - } - catch (XmlException e) - { - string message = string.Format("Unable to read element '{0}' content as string", m_Reader.Name); - throw new IcdXmlException(message, e, e.LineNumber, e.LinePosition); - } - } - public string ReadOuterXml() { try @@ -175,6 +162,19 @@ namespace ICD.Common.Utils.Xml } } + public string ReadElementContentAsString() + { + try + { + return m_Reader.ReadElementContentAsString(); + } + catch (XmlException e) + { + string message = string.Format("Unable to read element '{0}' content as string", m_Reader.Name); + throw new IcdXmlException(message, e, e.LineNumber, e.LinePosition); + } + } + public long ReadElementContentAsLong() { try @@ -199,6 +199,13 @@ namespace ICD.Common.Utils.Xml } } + public bool ReadElementContentAsBoolean() + { + // ReadElementContentAsBoolean() is too case sensitive + string value = ReadElementContentAsString(); + return bool.Parse(value); + } + #endregion } } diff --git a/ICD.Common.Utils/Xml/XmlUtils.cs b/ICD.Common.Utils/Xml/XmlUtils.cs index d84a455..7a58a44 100644 --- a/ICD.Common.Utils/Xml/XmlUtils.cs +++ b/ICD.Common.Utils/Xml/XmlUtils.cs @@ -396,9 +396,8 @@ namespace ICD.Common.Utils.Xml [PublicAPI] public static bool ReadChildElementContentAsBoolean(string xml, string childElement) { - // IcdXmlReader.ReadElementContentAsBoolean() is too case sensitive - string output = ReadChildElementContentAsString(xml, childElement); - return bool.Parse(output); + using (IcdXmlReader reader = GetChildElement(xml, childElement)) + return reader.ReadElementContentAsBoolean(); } ///