本文整理匯總了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();
}