void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { writer.WriteStartObject(); writer.WritePropertyName("coin_identifier"); writer.WriteObjectValue(CoinIdentifier); writer.WritePropertyName("coin_action"); writer.WriteStringValue(CoinAction.ToString()); writer.WriteEndObject(); }
public CoinChange(CoinIdentifier coinIdentifier, CoinAction coinAction) { if (coinIdentifier == null) { throw new ArgumentNullException(nameof(coinIdentifier)); } CoinIdentifier = coinIdentifier; CoinAction = coinAction; }
internal static CoinChange DeserializeCoinChange(JsonElement element) { CoinIdentifier coinIdentifier = default; CoinAction coinAction = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("coin_identifier")) { coinIdentifier = CoinIdentifier.DeserializeCoinIdentifier(property.Value); continue; } if (property.NameEquals("coin_action")) { coinAction = new CoinAction(property.Value.GetString()); continue; } } return(new CoinChange(coinIdentifier, coinAction)); }