/// <summary> /// Writes this schema to a <see cref="JsonWriter"/> using the specified <see cref="JSchemaResolver"/>. /// </summary> /// <param name="writer">A <see cref="JsonWriter"/> into which this method will write.</param> /// <param name="settings">The settings used to write the schema.</param> public void WriteTo(JsonWriter writer, JSchemaWriterSettings settings) { ValidationUtils.ArgumentNotNull(writer, nameof(writer)); ValidationUtils.ArgumentNotNull(settings, nameof(settings)); WriteToInternal(writer, settings); }
/// <summary> /// Returns the JSON for this schema using the specified <see cref="SchemaVersion"/>. /// </summary> /// <param name="version">The <see cref="SchemaVersion"/> used to create JSON for this schema.</param> /// <returns>The JSON for this schema.</returns> public string ToString(SchemaVersion version) { JSchemaWriterSettings settings = version != Schema.SchemaVersion.Unset ? new JSchemaWriterSettings { Version = version } : null; return(ToStringInternal(settings)); }
private string ToStringInternal(JSchemaWriterSettings settings) { StringWriter writer = new StringWriter(CultureInfo.InvariantCulture); JsonTextWriter jsonWriter = new JsonTextWriter(writer); jsonWriter.Formatting = Formatting.Indented; WriteToInternal(jsonWriter, settings); return(writer.ToString()); }
private void WriteToInternal(JsonWriter writer, JSchemaWriterSettings settings) { JSchemaWriter schemaWriter = new JSchemaWriter(writer, settings); schemaWriter.WriteSchema(this); }
/// <summary> /// Writes this schema to a <see cref="JsonWriter"/> using the specified <see cref="JSchemaResolver"/>. /// </summary> /// <param name="writer">A <see cref="JsonWriter"/> into which this method will write.</param> /// <param name="settings">The settings used to write the schema.</param> public void WriteTo(JsonWriter writer, JSchemaWriterSettings settings) { ValidationUtils.ArgumentNotNull(writer, "writer"); ValidationUtils.ArgumentNotNull(settings, "settings"); WriteToInternal(writer, settings); }