From 29e1ef82bb3c30fcfff63516e398babfd7730f63 Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Thu, 15 Feb 2018 14:44:21 -0500 Subject: [PATCH] Extension method for writing a Type as a JSON value --- ICD.Common.Utils/Extensions/JsonExtensions.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ICD.Common.Utils/Extensions/JsonExtensions.cs b/ICD.Common.Utils/Extensions/JsonExtensions.cs index 22ca920..0d9ce11 100644 --- a/ICD.Common.Utils/Extensions/JsonExtensions.cs +++ b/ICD.Common.Utils/Extensions/JsonExtensions.cs @@ -34,6 +34,21 @@ namespace ICD.Common.Utils.Extensions jObject.WriteTo(extends, converter); } + /// + /// Writes the type value. + /// + /// + /// + [PublicAPI] + public static void WriteType(this JsonWriter extends, Type type) + { + if (extends == null) + throw new ArgumentNullException("extends"); + + string assemblyName = type == null ? null : type.AssemblyQualifiedName; + extends.WriteValue(assemblyName); + } + /// /// Gets the current value as an integer. ///