diff --git a/ICD.Common.Utils/Xml/XmlUtils.cs b/ICD.Common.Utils/Xml/XmlUtils.cs index 9ad62a8..9cf03a8 100644 --- a/ICD.Common.Utils/Xml/XmlUtils.cs +++ b/ICD.Common.Utils/Xml/XmlUtils.cs @@ -972,6 +972,22 @@ namespace ICD.Common.Utils.Xml return ReadDictFromXml(xml, rootElement, childElement, keyElement, valueElement, readKey, readValue); } + /// + /// Calls childElementCallback for each item in the list. + /// + /// + /// + /// + /// + public static IEnumerable ReadListFromXml(string xml, string childElement, Func readChild) + { + if (readChild == null) + throw new ArgumentNullException("readChild"); + + foreach (string child in GetChildElementsAsString(xml, childElement)) + yield return readChild(child); + } + /// /// Calls childElementCallback for each item in the list. /// @@ -988,10 +1004,22 @@ namespace ICD.Common.Utils.Xml if (!TryGetChildElementAsString(xml, rootElement, out xml)) yield break; - foreach (string child in GetChildElementsAsString(xml, childElement)) - yield return readChild(child); + foreach (T child in ReadListFromXml(xml, childElement, readChild)) + yield return child; } + /// + /// Deserializes the xml to a list. + /// + /// + /// + /// + public static IEnumerable ReadListFromXml(string xml, string childElement) + { + Func readChild = IcdXmlConvert.DeserializeObject; + + return ReadListFromXml(xml, childElement, readChild); + } /// /// Deserializes the xml to a list.