public Amount CommodityAmount(Commodity commodity = null) { if (commodity == null) { if (IsSingleAmount) { return(SingleAmount); } else if (!IsEmpty) { // Try stripping annotations before giving an error. Balance balance = StripAnnotations(new AnnotationKeepDetails()); if (balance.IsSingleAmount) { return(balance.SingleAmount); } throw new AmountError(String.Format(AmountError.ErrorMessageRequestedAmountOfBalanceWithMultipleCommodities, balance)); } } else if (!IsEmpty) { Amount amount = null; Amounts.TryGetValue(commodity, out amount); return(amount); } return(null); }