/// <summary>
 /// Asynchronously writes the json value (primitive, IDictionary or IEnumerable) to the underlying json writer.
 /// </summary>
 /// <param name="jsonWriter">The <see cref="JsonWriter"/> to write to.</param>
 /// <param name="propertyValue">value to write.</param>
 /// <returns>A task that represents the asynchronous write operation.</returns>
 private static async Task WriteJsonValueAsync(this IJsonWriterAsync jsonWriter, object propertyValue)
 {
     if (propertyValue == null)
     {
         await jsonWriter.WriteValueAsync((string)null).ConfigureAwait(false);
     }
     else if (EdmLibraryExtensions.IsPrimitiveType(propertyValue.GetType()))
     {
         await jsonWriter.WritePrimitiveValueAsync(propertyValue).ConfigureAwait(false);
     }
     else
     {
         IDictionary <string, object> objectValue = propertyValue as IDictionary <string, object>;
         if (objectValue != null)
         {
             await jsonWriter.WriteJsonObjectValueAsync(objectValue, null /*typeName */).ConfigureAwait(false);
         }
         else
         {
             IEnumerable arrayValue = propertyValue as IEnumerable;
             Debug.Assert(arrayValue != null, "arrayValue != null");
             await jsonWriter.WriteJsonArrayValueAsync(arrayValue).ConfigureAwait(false);
         }
     }
 }