Exemple #1
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));
        }
        internal static Coin DeserializeCoin(JsonElement element)
        {
            CoinIdentifier coinIdentifier = default;
            Amount         amount         = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("coin_identifier"))
                {
                    coinIdentifier = CoinIdentifier.DeserializeCoinIdentifier(property.Value);
                    continue;
                }
                if (property.NameEquals("amount"))
                {
                    amount = Amount.DeserializeAmount(property.Value);
                    continue;
                }
            }
            return(new Coin(coinIdentifier, amount));
        }