Пример #1
0
        public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var d = value as DateOffset;

            if (d == null)
            {
                return(DependencyProperty.UnsetValue);
            }

            return(DateOffsetFormatter.GetUnitString(d.Offset, d.Unit));
        }
Пример #2
0
        public override object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values.Length < 2 || !(values[0] is DateUnit) || !(values[1] is int?))
            {
                return(DependencyProperty.UnsetValue);
            }


            var unit   = (DateUnit)values[0];
            int?offset = (int?)values[1];

            return(DateOffsetFormatter.GetUnitString(offset, unit));
        }
Пример #3
0
        public void UnitNegative()
        {
            var str = DateOffsetFormatter.GetUnitString(-1, DateUnit.Day);

            Assert.AreEqual(PluralsHelper.days[0], str);
        }
Пример #4
0
        public void OffsetNull()
        {
            var str = DateOffsetFormatter.GetUnitString(null, DateUnit.Day);

            Assert.AreEqual(PluralsHelper.days[2], str);
        }