public Calculation AddToSession(CalculationInfo info) { if (Current == null || (Current.Modified - DateTime.Now).TotalMinutes > TIMEOUT_MINUTES) { Current = new ScratchpadItem(); Items.Add(Current); } return(Current.AddCalculation(info)); }
public Calculation AddCalculation(CalculationInfo info) { Calculation calc = (Calculation)Activator.CreateInstance(info.BackingCalculationType); if (typeof(ContextualCalculation).IsAssignableFrom(calc.GetType())) { _contextualCalculations.Add((ContextualCalculation)calc); } else { _contextlessCalculations.Add((ContextlessCalculation)calc); } return(calc); }
private void RecursiveAdd(Queue <string> path, BrowserInfo parent, Calculation calc) { if (path.Count > 1) { string childId = path.Dequeue(); BrowserInfo child = parent.Children.FirstOrDefault(bi => bi.Name == childId); if (child == null) { child = new BrowserInfo(childId); parent._children.Add(child); } RecursiveAdd(path, child, calc); } else { CalculationInfo info = new CalculationInfo(calc); parent._children.Add(info); } }
public Calculation AddCalculation(CalculationInfo info) { Modified = DateTime.Now; return(Calculations.AddCalculation(info)); }