Exemple #1
0
        private MoneyRequest(Money amount, MoneyRequestType type, bool subtractFee)
        {
            if (type == MoneyRequestType.AllRemaining || type == MoneyRequestType.Change)
            {
                if (amount != null)
                {
                    throw new ArgumentException($"{nameof(amount)} must be null.");
                }
            }
            else if (type == MoneyRequestType.Value)
            {
                if (amount is null)
                {
                    throw new ArgumentNullException($"{nameof(amount)} cannot be null.");
                }
                else if (amount <= Money.Zero)
                {
                    throw new ArgumentOutOfRangeException($"{nameof(amount)} must be positive.");
                }
            }
            else
            {
                throw new NotSupportedException($"{nameof(type)} is not supported: {type}.");
            }

            Amount      = amount;
            Type        = type;
            SubtractFee = subtractFee;
        }
Exemple #2
0
 private MoneyRequest(Money?amount, MoneyRequestType type, bool subtractFee)
 {
     if (type is MoneyRequestType.AllRemaining or MoneyRequestType.Change)
     {
         if (amount is not null)
         {
             throw new ArgumentException("Must be null.", nameof(amount));
         }
     }
 private MoneyRequest(Money amount, MoneyRequestType type, bool subtractFee)
 {
     if (type is MoneyRequestType.AllRemaining or MoneyRequestType.Change)
     {
         if (amount is { })