private ProductSettings.ProductRequirements ExtractProductRequirementsRoot(XmlNodeList productRequirementsList) { ProductSettings.ProductRequirements requirementsRoot = new ProductSettings.ProductRequirements(); if (productRequirementsList.Count > 0) { requirementsRoot = ExtractProductRequirements(productRequirementsList)[0]; } return(requirementsRoot); }
public bool HandlersResult(ref ProductSettings.ProductRequirements requirements) { bool resB = true; if ((requirements.RequirementList == null) || (requirements.RequirementList == null) || (requirements.RequirementList.Count + requirements.RequirementsList.Count == 0)) { return(resB); } LogicalOperatorType logicaloperatorType = (LogicalOperatorType)Enum.Parse(typeof(LogicalOperatorType), requirements.LogicalOperator); int reqCount = requirements.RequirementList.Count + requirements.RequirementsList.Count; List <bool> arrBool = new List <bool>(); foreach (var req in requirements.RequirementList) { resB = HandlersReqResult(req); if ((reqCount > 1) && ((resB && (logicaloperatorType == LogicalOperatorType.OR)) || (!resB && (logicaloperatorType == LogicalOperatorType.AND)))) { #if DEBUG Logger.GetLogger().Info(reqCount + " Requirements {" + logicaloperatorType + "} => " + resB); #endif if (!resB) { requirements.UnfulfilledRequirementType = req.Type; requirements.UnfulfilledRequirementDelta = req.Delta; } return(resB); } arrBool.Add(resB); } foreach (ProductSettings.ProductRequirements reqs in requirements.RequirementsList) { ProductSettings.ProductRequirements reqsCopy = reqs; resB = HandlersResult(ref reqsCopy); if ((reqCount > 1) && ((resB && (logicaloperatorType == LogicalOperatorType.OR)) || (!resB && (logicaloperatorType == LogicalOperatorType.AND)))) { #if DEBUG Logger.GetLogger().Info(reqCount + " Requirements {" + logicaloperatorType + "} => " + resB); #endif return(resB); } arrBool.Add(resB); } resB = bool.Parse(CompareLogicalOper(arrBool.ToArray(), logicaloperatorType)); #if DEBUG Logger.GetLogger().Info(((reqCount > 1) ? reqCount.ToString() + " " : "") + "Requirements {" + logicaloperatorType + "} => " + resB); #endif return(resB); }
private List <ProductSettings.ProductRequirements> ExtractProductRequirements(XmlNodeList productRequirementsList) { List <ProductSettings.ProductRequirements> requirementsList = new List <ProductSettings.ProductRequirements>(); foreach (XmlNode requirementsNode in productRequirementsList) { ProductSettings.ProductRequirements requirements = new ProductSettings.ProductRequirements { LogicalOperator = XmlParser.GetStringAttribute(requirementsNode, "Requirements", "logicalOp") }; if (string.IsNullOrEmpty(requirements.LogicalOperator)) { requirements.LogicalOperator = Enum.GetName(typeof(RequirementHandlers.LogicalOperatorType), RequirementHandlers.LogicalOperatorType.AND); //default value } requirements.RequirementList = ExtractProductRequirement(requirementsNode.SelectNodes("Requirement")); requirements.RequirementsList = ExtractProductRequirements(requirementsNode.SelectNodes("Requirements")); requirementsList.Add(requirements); } return(requirementsList); }