/// <summary> /// Serializes a <see cref="Parameter"/> value according to its components. /// </summary> /// <param name="key">The <see cref="ParameterKey"/> component to serialize.</param> /// <param name="value">The referable <see cref="ParameterBody"/> component to serialize.</param> /// <returns>The <see cref="JsonValue"/>.</returns> protected virtual JsonValue SerializeParameter(ParameterKey key, Referable <ParameterBody> value) { if (value.IsReference) { return(SerializeReference(value.Reference)); } return(SerializeParameter(key, value.Value)); }
/// <summary> /// Sets a property in the specified <see cref="JsonObject"/>. /// </summary> /// <param name="container">The object to set the property on.</param> /// <param name="key">The property name in <paramref name="container"/>.</param> /// <param name="value">The value.</param> /// <param name="required">A value indicating whether the property is required.</param> protected virtual void SetJsonObject <T>(JsonObject container, string key, Referable <T> value, bool required = false) where T : class, IEquatable <T> { if (!value.HasValue) { if (required) { container.Add(key, null); } } else if (value.IsReference) { container.Add(key, SerializeReference(value.Reference)); } else { container.Add(key, Serialize(value.Value)); } }