本文整理匯總了C#中Newtonsoft.Json.JsonTextWriter.WriteNonDefault方法的典型用法代碼示例。如果您正苦於以下問題:C# JsonTextWriter.WriteNonDefault方法的具體用法?C# JsonTextWriter.WriteNonDefault怎麽用?C# JsonTextWriter.WriteNonDefault使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Newtonsoft.Json.JsonTextWriter
的用法示例。
在下文中一共展示了JsonTextWriter.WriteNonDefault方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Serialize
public string Serialize() {
var s = new StringWriter();
var w = new JsonTextWriter(s);
w.WriteStartObject();
w.Write(nameof(CarId), CarId);
w.Write(nameof(TrackId), TrackId);
w.Write(nameof(StartedAt), StartedAt);
w.Write(nameof(Time), Time);
w.Write(nameof(BestLap), BestLap);
w.Write(nameof(BestLapId), BestLapId);
w.WriteNonDefault(nameof(GoneOffroad), GoneOffroad);
w.WriteNonDefault(nameof(Penalties), Penalties);
w.WriteNonDefault(nameof(MaxSpeed), MaxSpeed, "F1");
w.WriteNonDefault(nameof(Distance), Distance, "F1");
w.WriteNonDefault(nameof(FuelBurnt), FuelBurnt, "F1");
w.WriteNonDefault(nameof(LongestAirborne), LongestAirborne, "F3");
w.WriteNonDefault(nameof(LongestWheelie), LongestWheelie, "F3");
w.WriteNonDefault(nameof(LongestTwoWheels), LongestTwoWheels, "F3");
w.WriteNonDefault(nameof(TotalAirborne), TotalAirborne, "F2");
w.WriteNonDefault(nameof(TotalWheelie), TotalWheelie, "F2");
w.WriteNonDefault(nameof(TotalTwoWheels), TotalTwoWheels, "F2");
w.WriteNonDefault(nameof(TotalTyreWear), TotalTyreWear, "F3");
w.WriteEndObject();
return s.ToString();
}