예제 #1
0
        public void EvalCustomVariables(XmlNode productCustomVars)
        {
            if (productCustomVars != null && productCustomVars.HasChildNodes)
            {
                RequirementHandlers reqHandlers = new RequirementHandlers();
                foreach (XmlNode CustomVar in productCustomVars.ChildNodes)
                {
                    ProductSettings.ProductRequirement requirement = new ProductSettings.ProductRequirement
                    {
                        Type            = XmlParser.GetStringValue(CustomVar, "Type"),
                        LogicalOperator = XmlParser.GetStringAttribute(CustomVar, "Keys", "logicalOp")
                    };
                    if (string.IsNullOrEmpty(requirement.LogicalOperator))
                    {
                        requirement.LogicalOperator = Enum.GetName(typeof(RequirementHandlers.LogicalOperatorType), RequirementHandlers.LogicalOperatorType.AND); //default value
                    }
                    requirement.Keys = new List <ProductSettings.RequirementKey>();
                    foreach (XmlNode requirementKey in CustomVar.SelectNodes("Keys/Key"))
                    {
                        ProductSettings.RequirementKey reqKey;
                        reqKey.Value = XmlParser.GetStringValue(requirementKey);
                        reqKey.Type  = XmlParser.GetStringAttribute(requirementKey, "type");

                        requirement.Keys.Add(reqKey);
                    }
                    string newElementName = XmlParser.GetStringAttribute(CustomVar, "name");
                    if (newElementName != "")
                    {
                        XmlElement elem = _xmlDoc.CreateElement(newElementName);
                        elem.InnerText = reqHandlers.EvalRequirement(requirement);
                        productCustomVars.AppendChild(elem);
                    }
                }
            }
        }
예제 #2
0
        private List <ProductSettings.ProductRequirement> ExtractProductRequirement(XmlNodeList requirementsNode)
        {
            List <ProductSettings.ProductRequirement> requirementList = new List <ProductSettings.ProductRequirement>();

            foreach (XmlNode requirementNode in requirementsNode)
            {
                ProductSettings.ProductRequirement requirement = new ProductSettings.ProductRequirement
                {
                    Type            = XmlParser.GetStringValue(requirementNode, "Type"),
                    LogicalOperator = XmlParser.GetStringAttribute(requirementNode, "Keys", "logicalOp"),
                    Delta           = XmlParser.GetStringValue(requirementNode, "Delta")
                };
                if (string.IsNullOrEmpty(requirement.LogicalOperator))
                {
                    requirement.LogicalOperator = Enum.GetName(typeof(RequirementHandlers.LogicalOperatorType), RequirementHandlers.LogicalOperatorType.AND); //default value
                }
                requirement.Keys = new List <ProductSettings.RequirementKey>();
                foreach (XmlNode requirementKey in requirementNode.SelectNodes("Keys/Key"))
                {
                    ProductSettings.RequirementKey reqKey;
                    reqKey.Value = XmlParser.GetStringValue(requirementKey);
                    reqKey.Type  = XmlParser.GetStringAttribute(requirementKey, "type");
                    requirement.Keys.Add(reqKey);
                }

                requirement.Value         = XmlParser.GetStringValue(requirementNode, "Value");
                requirement.ValueOperator = XmlParser.GetStringAttribute(requirementNode, "Value", "compareOp");

                requirementList.Add(requirement);
            }

            return(requirementList);
        }