1234567891011121314151617181920212223242526272829303132333435363738394041 |
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- using System.Net.Http.Headers;
- namespace InABox.WPF
- {
- public class DoubleCalculatorFunction : AbstractCalculatorFunction<double, NumericCalculatorType>
- {
-
- protected override double Calculate(double current, double next, NumericCalculatorType type)
- {
- var result = type switch
- {
- NumericCalculatorType.Sum => current + next,
- NumericCalculatorType.Product => current * next,
- NumericCalculatorType.Subtraction => current - next,
- NumericCalculatorType.Maximum => current > next ? current : next,
- NumericCalculatorType.Minimum => current < next ? current : next,
- _ => current
- };
- return result;
- }
- }
- public class DoubleArrayConverter : AbstractNumericArrayConverter<double>
- {
- protected override double[] Convert(IEnumerable<string> values)
- {
- var result = values.Select(double.Parse).ToArray();
- return result;
- }
- }
-
- public class DoubleCalculator : AbstractNumericCalculator<double, DoubleCalculatorFunction>
- {
- [TypeConverter(typeof(DoubleArrayConverter))]
- public override double[] Constants { get; set; }
- }
-
- }
|