mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-13 11:44:57 +00:00
Merge branch 'feat/XmlUtilsRoku' of Common/Utils into ConnectPro_v1.3
This commit is contained in:
@@ -6,10 +6,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
|
||||
### Added
|
||||
- Added Shim to read a list from xml with no root element
|
||||
|
||||
### Changed
|
||||
- Fixed JSON DateTime parsing in .Net Standard
|
||||
- Fixed threading exception in TypeExtensions
|
||||
|
||||
|
||||
## [9.4.0] - 2019-05-10
|
||||
### Added
|
||||
- Added extension method for peeking queues
|
||||
|
||||
@@ -972,6 +972,22 @@ namespace ICD.Common.Utils.Xml
|
||||
return ReadDictFromXml(xml, rootElement, childElement, keyElement, valueElement, readKey, readValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calls childElementCallback for each item in the list.
|
||||
/// </summary>
|
||||
/// <param name="xml"></param>
|
||||
/// <param name="rootElement"></param>
|
||||
/// <param name="childElement"></param>
|
||||
/// <param name="readChild"></param>
|
||||
public static IEnumerable<T> ReadListFromXml<T>(string xml, string childElement, Func<string, T> readChild)
|
||||
{
|
||||
if (readChild == null)
|
||||
throw new ArgumentNullException("readChild");
|
||||
|
||||
foreach (string child in GetChildElementsAsString(xml, childElement))
|
||||
yield return readChild(child);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calls childElementCallback for each item in the list.
|
||||
/// </summary>
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the xml to a list.
|
||||
/// </summary>
|
||||
/// <param name="xml"></param>
|
||||
/// <param name="rootElement"></param>
|
||||
/// <param name="childElement"></param>
|
||||
public static IEnumerable<T> ReadListFromXml<T>(string xml, string childElement)
|
||||
{
|
||||
Func<string, T> readChild = IcdXmlConvert.DeserializeObject<T>;
|
||||
|
||||
return ReadListFromXml(xml, childElement, readChild);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the xml to a list.
|
||||
|
||||
Reference in New Issue
Block a user