/**********************************************************************************************//** * Evaluate by pairs. * * \author Ilan Hindy * \date 29/09/2016 * * \param list1 The first list. * \param list2 The second list. * \param evaluateExpressionFunc The evaluate expression function. * * \return true if it succeeds, false if it fails. * . **************************************************************************************************/ private bool EvaluateByPairs(List <dynamic> list1, List <dynamic> list2, EvaluateExpression evaluateExpressionFunc) { ListEvaluationModes evaluationMode = or[brp.ork.ListEvaluationMode]; if (list1.Count != list2.Count) { if (evaluationMode == ListEvaluationModes.AllTrueFromAllVluesPairs) { return(false); } } int count = Math.Min(list1.Count, list2.Count); List <Parameters> allPossiblePairs = new List <Parameters>(); for (int idx = 0; idx < count; idx++) { allPossiblePairs.Add(new Parameters() { parameter1 = list1[idx], parameter2 = list2[idx] }); } if (evaluationMode == ListEvaluationModes.AllTrueFromAllVluesPairs) { return(!allPossiblePairs.Any(pair => EvaluatePair(pair.parameter1, pair.parameter2, evaluateExpressionFunc) == false)); } else //evaluationMode == ListEvaluationModes.OneTrueFromAllValuesPairs { return(allPossiblePairs.Any(pair => EvaluatePair(pair.parameter1, pair.parameter2, evaluateExpressionFunc) == true)); } }
/**********************************************************************************************//** * Evaluate all to all. * * \author Ilan Hindy * \date 29/09/2016 * * \param list1 The first list. * \param list2 The second list. * \param evaluateExpressionFunc The evaluate expression function. * * \return true if it succeeds, false if it fails. * . **************************************************************************************************/ private bool EvaluateAllToAll(List <dynamic> list1, List <dynamic> list2, EvaluateExpression evaluateExpressionFunc) { ListEvaluationModes evaluationMode = or[brp.ork.ListEvaluationMode]; List <Parameters> allPossiblePairs = new List <Parameters>(); foreach (dynamic parameterFromList1 in list1) { foreach (dynamic parameterFromList2 in list2) { allPossiblePairs.Add(new Parameters() { parameter1 = parameterFromList1, parameter2 = parameterFromList2 }); } } if (evaluationMode == ListEvaluationModes.AllTrueFromAllValuesToAllValues) { return(!allPossiblePairs.Any(pair => EvaluatePair(pair.parameter1, pair.parameter2, evaluateExpressionFunc) == false)); } else // evaluationMode == ListEvaluationModes.OneTrueFromAllValuesToAllValues { return(allPossiblePairs.Any(pair => EvaluatePair(pair.parameter1, pair.parameter2, evaluateExpressionFunc) == true)); } }
/**********************************************************************************************//** * Evaluates. * * \author Ilan Hindy * \date 29/09/2016 * * \param list1 The first list. * \param list2 The second list. * \param evaluateExpressionFunc The evaluate expression function. * * \return true if it succeeds, false if it fails. * . **************************************************************************************************/ private bool Evaluate(List <dynamic> list1, List <dynamic> list2, EvaluateExpression evaluateExpressionFunc) { if (list1.Count == 0 || list2.Count == 0) { return(false); } ListEvaluationModes evaluationMode = or[brp.ork.ListEvaluationMode]; switch (evaluationMode) { case ListEvaluationModes.AllTrueFromAllValuesToAllValues: return(EvaluateAllToAll(list1, list2, evaluateExpressionFunc)); case ListEvaluationModes.OneTrueFromAllValuesToAllValues: return(EvaluateAllToAll(list1, list2, evaluateExpressionFunc)); case ListEvaluationModes.AllTrueFromAllVluesPairs: return(EvaluateByPairs(list1, list2, evaluateExpressionFunc)); case ListEvaluationModes.OneTrueFromAllValuesPairs: return(EvaluateByPairs(list1, list2, evaluateExpressionFunc)); default: return(false); } }
/**********************************************************************************************//** * Evaluate results. * * \author Ilan Hindy * \date 29/09/2016 * * \param evaluationResults The evaluation results. * * \return true if it succeeds, false if it fails. * . **************************************************************************************************/ private bool EvaluateResults(List <bool> evaluationResults) { ListEvaluationModes evaluationMode = or[brp.ork.ListEvaluationMode]; if (evaluationMode == ListEvaluationModes.AllTrueFromAllValuesToAllValues || evaluationMode == ListEvaluationModes.AllTrueFromAllVluesPairs) { return(!evaluationResults.Any(evaluationResult => evaluationResult == false)); } else { return(evaluationResults.Any(evaluationResult => evaluationResult == true)); } }
/**********************************************************************************************//** * Creates this object. * * \author Ilan Hindy * \date 29/09/2016 * * \param hostingElementType Type of the hosting element. * \param enable true to enable, false to disable. * \param oprtr The oprtr. * \param parameters Options for controlling the operation. * \param name (Optional) The name. * \param indexInList (Optional) List of index INS. * \param parameterOneToAll (Optional) The parameter one to all. * \param listEvaluationMode (Optional) The list evaluation mode. * **************************************************************************************************/ public void Create(HostingElementTypes hostingElementType, bool enable, Operators oprtr, AttributeList parameters, string name = "", int indexInList = 0, ListParameterOneOrAll parameterOneToAll = ListParameterOneOrAll.One, ListEvaluationModes listEvaluationMode = ListEvaluationModes.OneTrueFromAllValuesToAllValues) { or[brp.ork.HostingElementType] = hostingElementType; or[brp.ork.Enable] = enable; or[brp.ork.Operator] = oprtr; or[brp.ork.Parameters] = parameters; or[brp.ork.Name] = name; or[brp.ork.IndexInList] = indexInList; or[brp.ork.ListParameterOneOrAll] = parameterOneToAll; or[brp.ork.ListEvaluationMode] = listEvaluationMode; }