From ad7176506d480cbe18031d2be17f4a7f74d12784 Mon Sep 17 00:00:00 2001 From: Rashod Davis Date: Wed, 28 Nov 2018 11:28:11 -0500 Subject: [PATCH] feat: Added GetAttributeAsEnum xml utils method --- ICD.Common.Utils/Xml/XmlUtils.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ICD.Common.Utils/Xml/XmlUtils.cs b/ICD.Common.Utils/Xml/XmlUtils.cs index fa28888..6caecd0 100644 --- a/ICD.Common.Utils/Xml/XmlUtils.cs +++ b/ICD.Common.Utils/Xml/XmlUtils.cs @@ -145,6 +145,21 @@ namespace ICD.Common.Utils.Xml } } + /// + /// Gets the value of the attribute with the given name and returns as a bool. + /// + /// + /// + /// + /// + [PublicAPI] + public static T GetAttributeAsEnum(string xml, string name, bool ignoreCase) + where T : struct, IConvertible + { + string attribute = GetAttributeAsString(xml, name); + return EnumUtils.Parse(attribute, ignoreCase); + } + #endregion #region Recurse