本文整理汇总了C#中Newtonsoft.Json.JsonTextWriter.WriteOptionalProperty方法的典型用法代码示例。如果您正苦于以下问题:C# JsonTextWriter.WriteOptionalProperty方法的具体用法?C# JsonTextWriter.WriteOptionalProperty怎么用?C# JsonTextWriter.WriteOptionalProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Newtonsoft.Json.JsonTextWriter
的用法示例。
在下文中一共展示了JsonTextWriter.WriteOptionalProperty方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToJsonSafe
/// <summary>
/// Converts current not to JSON according to the avro specification.
/// </summary>
/// <param name="writer">The writer.</param>
/// <param name="seenSchemas">The seen schemas.</param>
internal override void ToJsonSafe(JsonTextWriter writer, HashSet<NamedSchema> seenSchemas)
{
if (seenSchemas.Contains(this))
{
writer.WriteValue(this.FullName);
return;
}
seenSchemas.Add(this);
writer.WriteStartObject();
writer.WriteProperty("type", "fixed");
writer.WriteProperty("name", this.FullName);
writer.WriteOptionalProperty("aliases", this.Aliases);
writer.WriteProperty("size", this.Size);
writer.WriteEndObject();
}
示例2: ToJsonSafe
/// <summary>
/// Converts current not to json according to the avro specification.
/// </summary>
/// <param name="writer">The writer.</param>
/// <param name="seenSchemas">The seen schemas.</param>
internal override void ToJsonSafe(JsonTextWriter writer, HashSet<NamedSchema> seenSchemas)
{
if (seenSchemas.Contains(this))
{
writer.WriteValue(this.FullName);
return;
}
seenSchemas.Add(this);
writer.WriteStartObject();
writer.WriteProperty("type", "record");
writer.WriteProperty("name", this.FullName);
writer.WriteOptionalProperty("doc", this.Doc);
writer.WriteOptionalProperty("aliases", this.Aliases);
writer.WritePropertyName("fields");
writer.WriteStartArray();
this.fields.ForEach(_ => _.ToJson(writer, seenSchemas));
writer.WriteEndArray();
writer.WriteEndObject();
}
示例3: ToJsonSafe
/// <summary>
/// Converts current not to JSON according to the avro specification.
/// </summary>
/// <param name="writer">The writer.</param>
/// <param name="seenSchemas">The seen schemas.</param>
internal override void ToJsonSafe(JsonTextWriter writer, HashSet<NamedSchema> seenSchemas)
{
if (seenSchemas.Contains(this))
{
writer.WriteValue(this.FullName);
return;
}
seenSchemas.Add(this);
writer.WriteStartObject();
writer.WriteProperty("type", "enum");
writer.WriteProperty("name", this.FullName);
writer.WriteOptionalProperty("doc", this.Doc);
writer.WritePropertyName("symbols");
writer.WriteStartArray();
this.symbols.ForEach(writer.WriteValue);
writer.WriteEndArray();
writer.WriteEndObject();
}
示例4: ToJsonSafe
/// <summary>
/// Converts current not to JSON according to the avro specification.
/// </summary>
/// <param name="writer">The writer.</param>
/// <param name="seenSchemas">The seen schemas.</param>
internal override void ToJsonSafe(JsonTextWriter writer, HashSet<NamedSchema> seenSchemas)
{
writer.WriteStartObject();
writer.WriteProperty("name", this.FullName);
writer.WriteOptionalProperty("doc", this.Doc);
writer.WriteOptionalProperty("aliases", this.Aliases);
writer.WritePropertyName("type");
this.TypeSchema.ToJson(writer, seenSchemas);
writer.WriteEndObject();
}