/// <summary> /// Constructor for named schema class /// </summary> /// <param name="type">schema type</param> /// <param name="name">name</param> /// <param name="names">list of named schemas already read</param> protected NamedSchema(Type type, SchemaName name, IList <SchemaName> aliases, PropertyMap props, SchemaNames names) : base(type, props) { this.SchemaName = name; this.aliases = aliases; if (null != name.Name) // Added this check for anonymous records inside Message { if (!names.Add(name, this)) { throw new AvroException("Duplicate schema name " + name.Fullname); } } }
/// <summary> /// Writes named schema in JSON format /// </summary> /// <param name="writer">JSON writer</param> /// <param name="names">list of named schemas already written</param> /// <param name="encspace">enclosing namespace of the named schema</param> protected internal override void WriteJson(Newtonsoft.Json.JsonTextWriter writer, SchemaNames names, string encspace) { if (!names.Add(this)) { // schema is already in the list, write name only SchemaName schemaName = this.SchemaName; string name; if (schemaName.Namespace != encspace) { name = schemaName.Namespace + "." + schemaName.Name; // we need to add the qualifying namespace of the target schema if it's not the same as current namespace } else { name = schemaName.Name; } writer.WriteValue(name); } else { // schema is not in the list, write full schema definition base.WriteJson(writer, names, encspace); } }