Ejemplo n.º 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(decimal.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);
        }
Ejemplo n.º 2
0
        public ComparerResult CompareObjects(object x, object y, NumericRounding rounding)
        {
            var rxDecimal = caster.Execute(x);
            var ryDecimal = caster.Execute(y);

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

            return(CompareObjects(rxDecimal, ryDecimal));
        }