public List <int> GetNumberFactors( double number, dynamic algorithm, IUserAlgorithmStrategyProvider strategtProvider ) { var store = new UserAlgorithmStore(); var numberFactorsExecutor = new NumberFactorsCalculator(); var numbers = (List <double>)numberFactorsExecutor.GetNumberFactors((int)number, algorithm, strategtProvider, store); var result = numbers.Select(x => (int)x).ToList(); return(result); }
public void Execute(dynamic jObject, UserAlgorithmStore store) { var expressionCalculator = new UserExpressionCalculator(); var numberFactorsExecutor = new NumberFactorsCalculator(); WhileUserAlgorithmModel model = jObject.ToObject <WhileUserAlgorithmModel>(); var firstPart = expressionCalculator.Calculate(model.FirstPart, store); var secondPart = expressionCalculator.Calculate(model.SecondPart, store); switch (model.Condition) { case Condition.More: if (firstPart > secondPart) { numberFactorsExecutor.ExecuteAlgorithm(model.Algorithm, new UserAlgorithmStrategyProvider(), store); Execute(jObject, store); } break; case Condition.Less: if (firstPart < secondPart) { numberFactorsExecutor.ExecuteAlgorithm(model.Algorithm, new UserAlgorithmStrategyProvider(), store); Execute(jObject, store); } break; case Condition.Equals: if (firstPart == secondPart) { numberFactorsExecutor.ExecuteAlgorithm(model.Algorithm, new UserAlgorithmStrategyProvider(), store); Execute(jObject, store); } break; case Condition.NotEquals: if (firstPart != secondPart) { numberFactorsExecutor.ExecuteAlgorithm(model.Algorithm, new UserAlgorithmStrategyProvider(), store); Execute(jObject, store); } break; } }