示例#1
0
        public void SetCryptoData(CryptoData cryptoData)
        {
            var dict = GetCryptoData(null);

            dict.AddOrReplace(cryptoData.CryptoCode, cryptoData);
            SetCryptoData(dict);
        }
示例#2
0
        public Dictionary <string, CryptoData> GetCryptoData()
        {
            Dictionary <string, CryptoData> rates = new Dictionary <string, CryptoData>();
            var serializer = new Serializer(Dummy);

#pragma warning disable CS0618
            // Legacy
            if (Rate != 0.0m)
            {
                rates.TryAdd("BTC", new CryptoData()
                {
                    ParentEntity = this, Rate = Rate, CryptoCode = "BTC", TxFee = TxFee, FeeRate = new FeeRate(TxFee, 100), DepositAddress = DepositAddress
                });
            }
            if (CryptoData != null)
            {
                foreach (var prop in CryptoData.Properties())
                {
                    var r = serializer.ToObject <CryptoData>(prop.Value.ToString());
                    r.CryptoCode   = prop.Name;
                    r.ParentEntity = this;
                    rates.TryAdd(r.CryptoCode, r);
                }
            }
#pragma warning restore CS0618
            return(rates);
        }
示例#3
0
        public Dictionary <string, CryptoData> GetCryptoData(BTCPayNetworkProvider networkProvider, bool alwaysIncludeBTC = false)
        {
            Dictionary <string, CryptoData> rates = new Dictionary <string, CryptoData>();
            var        serializer = new Serializer(Dummy);
            CryptoData phantom    = null;

#pragma warning disable CS0618
            // Legacy
            if (alwaysIncludeBTC)
            {
                var btcNetwork = networkProvider?.GetNetwork("BTC");
                phantom = new CryptoData()
                {
                    ParentEntity = this, IsPhantomBTC = true, Rate = Rate, CryptoCode = "BTC", TxFee = TxFee, FeeRate = new FeeRate(TxFee, 100), DepositAddress = DepositAddress, Network = btcNetwork
                };
                rates.Add("BTC", phantom);
            }
            if (CryptoData != null)
            {
                foreach (var prop in CryptoData.Properties())
                {
                    if (prop.Name == "BTC" && phantom != null)
                    {
                        rates.Remove("BTC");
                    }
                    var r = serializer.ToObject <CryptoData>(prop.Value.ToString());
                    r.CryptoCode   = prop.Name;
                    r.ParentEntity = this;
                    r.Network      = networkProvider?.GetNetwork(r.CryptoCode);
                    rates.Add(r.CryptoCode, r);
                }
            }
#pragma warning restore CS0618
            return(rates);
        }