本文整理汇总了C#中Newtonsoft.Json.JsonTextWriter.WriteNullableProperty方法的典型用法代码示例。如果您正苦于以下问题:C# JsonTextWriter.WriteNullableProperty方法的具体用法?C# JsonTextWriter.WriteNullableProperty怎么用?C# JsonTextWriter.WriteNullableProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Newtonsoft.Json.JsonTextWriter
的用法示例。
在下文中一共展示了JsonTextWriter.WriteNullableProperty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToJsonString
internal string ToJsonString()
{
var sb = new StringBuilder();
using(var sw = new StringWriter(sb))
using(JsonWriter jw = new JsonTextWriter(sw))
{
jw.WriteStartObject();
jw.WritePropertyName("props");
jw.WriteStartObject();
jw.WriteNullableProperty("n_val", NVal)
.WriteNullableProperty("allow_mult", AllowMultiple)
.WriteNullableProperty("last_write_wins", LastWriteWins)
.WriteNullableProperty("r", RVal)
.WriteNullableProperty("rw", RwVal)
.WriteNullableProperty("dw", DwVal)
.WriteNullableProperty("w", WVal)
.WriteNullableProperty("pr", PrVal)
.WriteNullableProperty("pw", PwVal)
.WriteNonNullProperty("backend", Backend)
.WriteNullableProperty("notfound_ok", NotFoundOk)
.WriteNullableProperty("basic_quorum", BasicQuorum)
.WriteNullableProperty("has_precommit", HasPrecommit)
.WriteNullableProperty("has_postcommit", HasPostcommit);
if(PreCommitHooks != null)
{
jw.WritePropertyName("precommit");
jw.WriteStartArray();
PreCommitHooks.ForEach(hook => hook.WriteJson(jw));
jw.WriteEndArray();
}
if(PostCommitHooks != null)
{
jw.WritePropertyName("postcommit");
jw.WriteStartArray();
PostCommitHooks.ForEach(hook => hook.WriteJson(jw));
jw.WriteEndArray();
}
jw.WriteEndObject();
jw.WriteEndObject();
}
return sb.ToString();
}