mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-01-11 19:44:55 +00:00
feat: Adding overloads for reading XML attributes as GUIDs
This commit is contained in:
@@ -114,6 +114,22 @@ namespace ICD.Common.Utils.Xml
|
||||
return bool.Parse(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value of the attribute with the given name and returns as a GUID.
|
||||
/// </summary>
|
||||
/// <param name="extends"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
[PublicAPI]
|
||||
public static Guid GetAttributeAsGuid(this IcdXmlReader extends, string name)
|
||||
{
|
||||
if (extends == null)
|
||||
throw new ArgumentNullException("extends");
|
||||
|
||||
string value = extends.GetAttributeAsString(name);
|
||||
return new Guid(value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Recurse
|
||||
|
||||
@@ -145,6 +145,22 @@ namespace ICD.Common.Utils.Xml
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value of the attribute with the given name and returns as a GUID.
|
||||
/// </summary>
|
||||
/// <param name="xml"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
[PublicAPI]
|
||||
public static Guid GetAttributeAsGuid(string xml, string name)
|
||||
{
|
||||
using (IcdXmlReader reader = new IcdXmlReader(xml))
|
||||
{
|
||||
reader.ReadToNextElement();
|
||||
return reader.GetAttributeAsGuid(name);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value of the attribute with the given name and returns as a bool.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user