示例#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);
        }
示例#2
0
        public ComparerResult CompareObjects(object x, object y, DateTimeRounding rounding)
        {
            var rxDateTime = ConvertToDate(x);
            var ryDateTime = ConvertToDate(y);

            rxDateTime = rounding.GetValue(rxDateTime);
            ryDateTime = rounding.GetValue(ryDateTime);

            return(CompareObjects(rxDateTime, ryDateTime));
        }
示例#3
0
        public ComparerResult CompareObjects(object x, object y, DateTimeRounding rounding)
        {
            var rxDateTime = ConvertToDate(x);
            var ryDateTime = ConvertToDate(y);

            rxDateTime = rounding.GetValue(rxDateTime);
            ryDateTime = rounding.GetValue(ryDateTime);

            return CompareObjects(rxDateTime, ryDateTime);
        }
示例#4
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;
        }
        public void GetValue_ValueQuarterHourRoundingStyle_NewValue(DateTime value, Rounding.RoundingStyle roundingStyle, DateTime newValue)
        {
            var rounder = new DateTimeRounding(new TimeSpan(0, 0, 15, 0), roundingStyle);

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