Ejemplo n.º 1
0
        public static Currency GetCurrency(decimal value, CurrencyInfo info)
        {
            switch (info.Code)
            {
            case "USD":
            case "JPY":
            case "EUR":
            case "PLN":
                return(CurrencyWithCents.FromDecimal(value, info));

            case "ISK":
                return(CurrencyWithNoCents.FromDecimal(value, info));
            }
            return(null);
        }
Ejemplo n.º 2
0
        public static Currency GetCurrency(string value, CurrencyInfo info, CultureInfo culture)
        {
            switch (info.Code)
            {
            case "USD":
            case "JPY":
            case "EUR":
            case "PLN":
                return(CurrencyWithCents.Parse(value, info, culture));

            case "ISK":
                return(CurrencyWithNoCents.Parse(value, info, culture));
            }
            return(null);
        }
Ejemplo n.º 3
0
 public static CurrencyWithCents FromDecimal(decimal value, CurrencyInfo info)
 {
     return(new CurrencyWithCents((int)value, ((int)(value * 100)) % 100, info));
 }
Ejemplo n.º 4
0
 public CurrencyWithCents(int units, int cents, CurrencyInfo currencyInfo)
     : base(currencyInfo)
 {
     _units = units + cents / 100;
     _cents = cents % 100;
 }
Ejemplo n.º 5
0
 public static Currency GetCurrency(string value, CurrencyInfo info)
 {
     return(GetCurrency(value, info, CultureInfo.InvariantCulture));
 }
Ejemplo n.º 6
0
 public static Currency GetZero(CurrencyInfo info)
 {
     return(GetCurrency("0", info));
 }
Ejemplo n.º 7
0
 protected Currency(CurrencyInfo currencyInfo)
 {
     _currencyInfo = currencyInfo;
 }
Ejemplo n.º 8
0
 public CurrencyWithNoCents(int units, CurrencyInfo currencyInfo) : base(currencyInfo)
 {
     _units = units;
 }
Ejemplo n.º 9
0
 public static CurrencyWithNoCents FromDecimal(decimal value, CurrencyInfo info)
 {
     return(new CurrencyWithNoCents((int)value, info));
 }
Ejemplo n.º 10
0
        public static CurrencyWithNoCents Parse(string str, CurrencyInfo info, CultureInfo culture)
        {
            int units = int.Parse(str, culture);

            return(new CurrencyWithNoCents(units, info));
        }