mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-24 14:50:50 +01:00
29 lines
1 KiB
C#
29 lines
1 KiB
C#
using System;
|
|
using NBitcoin;
|
|
|
|
namespace BTCPayServer
|
|
{
|
|
public static class MoneyExtensions
|
|
{
|
|
public static decimal GetValue(this IMoney m, BTCPayNetwork network = null)
|
|
{
|
|
switch (m)
|
|
{
|
|
case Money money:
|
|
return money.ToDecimal(MoneyUnit.BTC);
|
|
// case MoneyBag mb:
|
|
// return mb.Select(money => money.GetValue(network)).Sum();
|
|
// case AssetMoney assetMoney:
|
|
// if (network is ElementsBTCPayNetwork elementsBTCPayNetwork)
|
|
// {
|
|
// return elementsBTCPayNetwork.AssetId == assetMoney.AssetId
|
|
// ? new Money(assetMoney.Quantity)
|
|
// : Money.Zero;
|
|
// }
|
|
// throw new NotSupportedException("IMoney type not supported");
|
|
default:
|
|
throw new NotSupportedException("IMoney type not supported");
|
|
}
|
|
}
|
|
}
|
|
}
|