示例#1
0
        public static Money <TCurrency> FromMinor <TCurrency>(decimal minor, IRoundingAdjuster adjuster)
            where TCurrency : Currency <TCurrency>
        {
            var major = Money <TCurrency> .UnderlyingUnit.ConvertToMajor(minor);

            return(FromMajor <TCurrency>(major, adjuster));
        }
示例#2
0
 public Money <TCurrency> Normalize(IRoundingAdjuster adjuster)
 {
     if (IsNormalized)
     {
         return(this);
     }
     return(MoneyFactory.FromMajor <TCurrency>(Amount, adjuster));
 }
示例#3
0
 public Money Normalize(IRoundingAdjuster adjuster)
 {
     if (IsNormalized)
     {
         return(this);
     }
     return(FromMajor(Amount, Currency, adjuster));
 }
示例#4
0
        public static Money <TCurrency> FromMajor <TCurrency>(decimal amount, IRoundingAdjuster adjuster)
            where TCurrency : Currency <TCurrency>
        {
            Require.NotNull(adjuster, nameof(adjuster));

            var     unit  = Money <TCurrency> .UnderlyingUnit;
            decimal major = unit.HasFixedDecimalPlaces
                ? adjuster.Round(amount, unit.DecimalPlaces)
                : amount;

            return(new Money <TCurrency>(major, true));
        }
        public RoundingMoneyAllocator(IRoundingAdjuster adjuster)
        {
            Require.NotNull(adjuster, nameof(adjuster));

            RoundingAdjuster = adjuster;
        }
示例#6
0
 public static IEnumerable <Money> Allocate(this Money @this, RatioArray ratios, IRoundingAdjuster adjuster)
 => new RoundingMoneyAllocator(adjuster).Allocate(@this, ratios);
示例#7
0
 public static IEnumerable <Money> Allocate(this Money @this, int count, IRoundingAdjuster adjuster)
 => new RoundingMoneyAllocator(adjuster).Allocate(@this, count);