예제 #1
0
            public override bool TryCreateStep(object value, out ValueGenerator.Step step)
            {
                if (value is float)
                {
                    step = new ComparableStep <float>((float)value, (prev, stepValue) =>
                    {
                        var next = prev + stepValue;
                        if (stepValue > 0 ? next <= prev : prev <= next)
                        {
                            throw new ArithmeticException($"Not enough precision to represent the next step; {prev:r} + {stepValue:r} = {next:r}.");
                        }
                        return(next);
                    });
                    return(true);
                }

                return(base.TryCreateStep(value, out step));
            }
예제 #2
0
 public sealed override IEnumerable GenerateRange(object start, object end, ValueGenerator.Step step)
 {
     return(GenerateRange((T)start, (T)end, (Step)step));
 }
예제 #3
0
 /// <summary>
 /// Creates a <see cref="Step"/> from the specified value if the current instance is able to
 /// use it to increment values of type <typeparamref name="T"/>. A return value indicates
 /// whether the creation succeeded.
 /// </summary>
 public override bool TryCreateStep(object value, out ValueGenerator.Step step)
 {
     Guard.ArgumentNotNull(value, nameof(value));
     step = null;
     return(false);
 }