feat: Adding overloads for reading XML attributes as GUIDs

This commit is contained in:
Chris Cameron
2020-04-18 18:42:13 -04:00
parent ffb217839c
commit 64405a1cd6
2 changed files with 32 additions and 0 deletions

View File

@@ -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

View File

@@ -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>