mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-04-12 12:07:05 +00:00
feat: Adding overloads for reading XML attributes as GUIDs
This commit is contained in:
parent
ffb217839c
commit
64405a1cd6
2 changed files with 32 additions and 0 deletions
|
|
@ -114,6 +114,22 @@ namespace ICD.Common.Utils.Xml
|
||||||
return bool.Parse(value);
|
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
|
#endregion
|
||||||
|
|
||||||
#region Recurse
|
#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>
|
/// <summary>
|
||||||
/// Gets the value of the attribute with the given name and returns as a bool.
|
/// Gets the value of the attribute with the given name and returns as a bool.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue