Пример #1
0
 void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 {
     writer.WriteStartObject();
     writer.WritePropertyName("coin_identifier");
     writer.WriteObjectValue(CoinIdentifier);
     writer.WritePropertyName("coin_action");
     writer.WriteStringValue(CoinAction.ToString());
     writer.WriteEndObject();
 }
Пример #2
0
        public CoinChange(CoinIdentifier coinIdentifier, CoinAction coinAction)
        {
            if (coinIdentifier == null)
            {
                throw new ArgumentNullException(nameof(coinIdentifier));
            }

            CoinIdentifier = coinIdentifier;
            CoinAction     = coinAction;
        }
Пример #3
0
        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));
        }