19 using System.Collections.Generic;
21 using Newtonsoft.Json.Linq;
22 using Newtonsoft.Json;
31 public string Name {
get;
set; }
36 public string Doc {
get;
set; }
73 if (
string.IsNullOrEmpty(name))
throw new ArgumentNullException(
"name",
"name cannot be null.");
91 for (
int i = 0; i < error.
Schemas.Count; ++i)
108 string name = jmessage.
Name;
115 JToken jresponse = jmessage.Value[
"response"];
116 var response =
Schema.ParseJson(jresponse, names, encspace);
118 JToken jerrors = jmessage.Value[
"errors"];
122 Schema errorSchema =
Schema.ParseJson(jerrors, names, encspace);
129 return new Message(name, doc, schema, response, uerrorSchema, oneway);
138 internal void writeJson(Newtonsoft.Json.JsonTextWriter writer, SchemaNames names,
string encspace)
140 writer.WriteStartObject();
141 JsonHelper.writeIfNotNullOrEmpty(writer,
"doc", this.
Doc);
148 writer.WritePropertyName(
"response");
152 if (
null != this.
Error)
154 writer.WritePropertyName(
"errors");
160 writer.WritePropertyName(
"one-way");
161 writer.WriteValue(
Oneway);
164 writer.WriteEndObject();
174 if (obj ==
this)
return true;
175 if (!(obj is
Message))
return false;
178 return this.
Name.Equals(that.
Name) &&
190 return Name.GetHashCode() +
202 protected static bool areEqual(
object o1,
object o2)
204 return o1 ==
null ? o2 == null : o1.Equals(o2);
override bool Equals(object obj)
Compares equality of two record schemas
internal override void WriteJsonFields(Newtonsoft.Json.JsonTextWriter writer, SchemaNames names, string encspace)
Writes the records schema in JSON format
Schema Response
Schema object for the 'response' attribute
static ? bool GetOptionalBoolean(JToken jtok, string field)
Retrieves the optional boolean property value for the given property name from the given JSON object.
override bool CanRead(Schema writerSchema)
Checks if this schema can read data written by the given schema.
override int GetHashCode()
Hash code function
Base class for all schema types
static bool areEqual(object o1, object o2)
Tests equality of two objects taking null values into account
override int GetHashCode()
Returns the hash code of this Message object
IList< Schema > Schemas
List of schemas in the union
internal override void WriteJson(Newtonsoft.Json.JsonTextWriter writer, SchemaNames names, string encspace)
Writes union schema in JSON format
RecordSchema Request
Anonymous record for the list of parameters for the request fields
Type
Enum for schema types
virtual internal void WriteJson(JsonTextWriter writer, SchemaNames names, string encspace)
Writes schema object in JSON format
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
string Name
Name of the message
override int GetHashCode()
Hash code function
string Doc
Documentation for the message
A class that contains a list of named schemas.
static string GetOptionalString(JToken jtok, string field)
Retrieves the optional string property value for the given property name from the given JSON object.
Message(string name, string doc, RecordSchema request, Schema response, UnionSchema error, bool? oneway)
Constructor for Message class
override bool Equals(Object obj)
Tests equality of this Message object with the passed object
override int GetHashCode()
Hash code function
bool? Oneway
Optional one-way attribute
UnionSchema Error
Union schema object for the 'error' attribute
static Schema Parse(string json)
Parses a given JSON string to create a new schema object
UnionSchema SupportedErrors
Explicitly defined protocol errors plus system added "string" error