mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-16 13:15:07 +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]
|
## [Unreleased]
|
||||||
|
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Added Shim to read a list from xml with no root element
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Fixed JSON DateTime parsing in .Net Standard
|
- Fixed JSON DateTime parsing in .Net Standard
|
||||||
- Fixed threading exception in TypeExtensions
|
- Fixed threading exception in TypeExtensions
|
||||||
|
|
||||||
|
|
||||||
## [9.4.0] - 2019-05-10
|
## [9.4.0] - 2019-05-10
|
||||||
### Added
|
### Added
|
||||||
- Added extension method for peeking queues
|
- Added extension method for peeking queues
|
||||||
|
|||||||
@@ -972,6 +972,22 @@ namespace ICD.Common.Utils.Xml
|
|||||||
return ReadDictFromXml(xml, rootElement, childElement, keyElement, valueElement, readKey, readValue);
|
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>
|
/// <summary>
|
||||||
/// Calls childElementCallback for each item in the list.
|
/// Calls childElementCallback for each item in the list.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -988,10 +1004,22 @@ namespace ICD.Common.Utils.Xml
|
|||||||
if (!TryGetChildElementAsString(xml, rootElement, out xml))
|
if (!TryGetChildElementAsString(xml, rootElement, out xml))
|
||||||
yield break;
|
yield break;
|
||||||
|
|
||||||
foreach (string child in GetChildElementsAsString(xml, childElement))
|
foreach (T child in ReadListFromXml(xml, childElement, readChild))
|
||||||
yield return readChild(child);
|
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>
|
/// <summary>
|
||||||
/// Deserializes the xml to a list.
|
/// Deserializes the xml to a list.
|
||||||
|
|||||||
Reference in New Issue
Block a user