Exemple #1
0
        public static Rounding Build(IColumnDefinition columnDefinition)
        {
            if (columnDefinition.Role != ColumnRole.Value)
            {
                throw new ArgumentException("The ColumnDefinition must have have a role defined as 'Value' and is defined as 'Key'", "columnDefinition");
            }

            Rounding rounding = null;

            switch (columnDefinition.Type)
            {
            case ColumnType.Text:
                break;

            case ColumnType.Numeric:
                rounding = new NumericRounding(double.Parse(columnDefinition.RoundingStep, NumberFormatInfo.InvariantInfo), columnDefinition.RoundingStyle);
                break;

            case ColumnType.DateTime:
                rounding = new DateTimeRounding(TimeSpan.Parse(columnDefinition.RoundingStep, NumberFormatInfo.InvariantInfo), columnDefinition.RoundingStyle);
                break;

            case ColumnType.Boolean:
                break;

            default:
                break;
            }

            return(rounding);
        }
Exemple #2
0
        public ComparerResult CompareObjects(object x, object y, NumericRounding rounding)
        {
            var rxDecimal = Convert.ToDecimal(x, NumberFormatInfo.InvariantInfo);
            var ryDecimal = Convert.ToDecimal(y, NumberFormatInfo.InvariantInfo);

            rxDecimal = rounding.GetValue(rxDecimal);
            ryDecimal = rounding.GetValue(ryDecimal);

            return(CompareObjects(rxDecimal, ryDecimal));
        }
Exemple #3
0
        public ComparerResult CompareObjects(object x, object y, NumericRounding rounding)
        {
            var rxDecimal = Convert.ToDecimal(x, NumberFormatInfo.InvariantInfo);
            var ryDecimal = Convert.ToDecimal(y, NumberFormatInfo.InvariantInfo);

            rxDecimal = rounding.GetValue(rxDecimal);
            ryDecimal = rounding.GetValue(ryDecimal);

            return CompareObjects(rxDecimal, ryDecimal);
        }
Exemple #4
0
        public ComparerResult CompareObjects(object x, object y, NumericRounding rounding)
        {
            var rxDecimal = converter.Convert(x);
            var ryDecimal = converter.Convert(y);

            rxDecimal = rounding.GetValue(rxDecimal);
            ryDecimal = rounding.GetValue(ryDecimal);

            return(CompareObjects(rxDecimal, ryDecimal));
        }
        public ComparerResult CompareObjects(object x, object y, NumericRounding rounding)
        {
            var rxDecimal = converter.Convert(x);
            var ryDecimal = converter.Convert(y);

            rxDecimal = rounding.GetValue(rxDecimal);
            ryDecimal = rounding.GetValue(ryDecimal);

            return CompareObjects(rxDecimal, ryDecimal);
        }
        public static Rounding Build(IColumnDefinition columnDefinition)
        {
            if (columnDefinition.Role != ColumnRole.Value)
                throw new ArgumentException("The ColumnDefinition must have have a role defined as 'Value' and is defined as 'Key'", "columnDefinition");

            Rounding rounding=null;
            switch (columnDefinition.Type)
            {
                case ColumnType.Text:
                    break;
                case ColumnType.Numeric:
                    rounding = new NumericRounding(double.Parse(columnDefinition.RoundingStep, NumberFormatInfo.InvariantInfo), columnDefinition.RoundingStyle);
                    break;
                case ColumnType.DateTime:
                    rounding = new DateTimeRounding(TimeSpan.Parse(columnDefinition.RoundingStep, NumberFormatInfo.InvariantInfo), columnDefinition.RoundingStyle);
                    break;
                case ColumnType.Boolean:
                    break;
                default:
                    break;
            }

            return rounding;
        }
        public void GetValue_ValueStepStyle_NewValue(decimal value, int step, Rounding.RoundingStyle roundingStyle, decimal newValue)
        {
            var rounder = new NumericRounding(step, roundingStyle);

            Assert.That(rounder.GetValue(value), Is.EqualTo(newValue));
        }