/// <summary> /// Writes Protocol in JSON format /// </summary> /// <param name="writer">JSON writer</param> /// <param name="names">list of named schemas already written</param> internal void WriteJson(Arch.CMessaging.Client.Newtonsoft.Json.JsonTextWriter writer, SchemaNames names) { writer.WriteStartObject(); JsonHelper.writeIfNotNullOrEmpty(writer, "protocol", this.Name); JsonHelper.writeIfNotNullOrEmpty(writer, "namespace", this.Namespace); JsonHelper.writeIfNotNullOrEmpty(writer, "doc", this.Doc); writer.WritePropertyName("types"); writer.WriteStartArray(); foreach (Schema type in this.Types) type.WriteJson(writer, names, this.Namespace); writer.WriteEndArray(); writer.WritePropertyName("messages"); writer.WriteStartObject(); foreach (KeyValuePair<string,Message> message in this.Messages) { writer.WritePropertyName(message.Key); message.Value.writeJson(writer, names, this.Namespace); } writer.WriteEndObject(); writer.WriteEndObject(); }
/// <summary> /// Writes the messages section of a protocol definition /// </summary> /// <param name="writer">writer</param> /// <param name="names">list of names written</param> /// <param name="encspace">enclosing namespace</param> internal void writeJson(Arch.CMessaging.Client.Newtonsoft.Json.JsonTextWriter writer, SchemaNames names, string encspace) { writer.WriteStartObject(); JsonHelper.writeIfNotNullOrEmpty(writer, "doc", this.Doc); if (null != this.Request) this.Request.WriteJsonFields(writer, names, null); if (null != this.Response) { writer.WritePropertyName("response"); Response.WriteJson(writer, names, encspace); } if (null != this.Error) { writer.WritePropertyName("errors"); this.Error.WriteJson(writer, names, encspace); } if (null != Oneway) { writer.WritePropertyName("one-way"); writer.WriteValue(Oneway); } writer.WriteEndObject(); }