From 5fb7636ed45dbc0c65f09e662650e086211c75eb Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Wed, 30 Jan 2019 10:52:44 -0500 Subject: [PATCH] feat: Extension method for reading JSON token as a Guid --- .../Extensions/JsonReaderExtensions.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ICD.Common.Utils/Extensions/JsonReaderExtensions.cs b/ICD.Common.Utils/Extensions/JsonReaderExtensions.cs index 0ef7078..5c4a023 100644 --- a/ICD.Common.Utils/Extensions/JsonReaderExtensions.cs +++ b/ICD.Common.Utils/Extensions/JsonReaderExtensions.cs @@ -190,6 +190,21 @@ namespace ICD.Common.Utils.Extensions return (T)(object)extends.GetValueAsInt(); } + /// + /// Gets the current value as a guid. + /// + /// + /// + [PublicAPI] + public static Guid GetValueAsGuid(this JsonReader extends) + { + if (extends == null) + throw new ArgumentNullException("extends"); + + string stringValue = extends.GetValueAsString(); + return new Guid(stringValue); + } + /// /// Deserializes an array of items from the reader's current value. ///