public void Define(string dest, string calcStr) { // pull out into command pattern var re = new Regex(@"(SUM|AVERAGE)\(([a-z]+\d+):([a-z]+\d+)\)", RegexOptions.IgnoreCase); var m = re.Match(calcStr); string command = m.Groups[1].Value; string start = m.Groups[2].Value; string end = m.Groups[3].Value; Tuple <int, int> indexStart = IndexParser.Parse(start); Tuple <int, int> indexEnd = IndexParser.Parse(end); ICalculation calc = AtlasGridCalculation.Value(start); // + 1 because we have added the first value already above.. for (var i = indexStart.Item2 + 1; i <= indexEnd.Item2; i++) { string grid = IndexParser.Generate(indexStart.Item1, i); // blah calc = ((AtlasGridCalculation)calc).Sum(grid); } if (command == "AVERAGE") { calc = new Average(calc, indexEnd.Item2 - indexStart.Item2); } _calcs.Add(dest, calc); }
public Subtraction(string val, AtlasGridCalculation chain) : base(val, chain) { }
public Unit(string val, AtlasGridCalculation chain) : base(val, chain) { }
protected AtlasGridCalculation(string key, AtlasGridCalculation chain = null) { _key = key; _chained = chain; }
public Multiplication(string val, AtlasGridCalculation chain) : base(val, chain) { }
public LoadedCalculation Multi(string key) { _calc = _calc.Multi(key); return(this); }
public LoadedCalculation Sub(string key) { _calc = _calc.Sub(key); return(this); }
public LoadedCalculation Value(string key) { _calc = AtlasGridCalculation.Value(key); return(this); }