Esempio n. 1
0
        public override void ExtractVariables(IDictionary <string, ExtractedVariable> variables)
        {
            var vPart = Element.Condition as VariableConditionPart;

            if (vPart != null)
            {
                var xV = new ExtractedVariable(vPart.VariableName);
                xV.AddValue(true.ToString());
                variables.Add(xV.Name, xV);
            }

            var opPart = Element.Condition as OperationConditionPart;

            if (opPart != null)
            {
                ExtractVars(opPart, variables);
            }

            foreach (var elem in Element.ConditionTrueElements)
            {
                VariableExtractionFactory.ExtractVariables(elem, variables, Parms);
            }

            if (Element.ConditionFalseElements != null)
            {
                foreach (var elem in Element.ConditionFalseElements)
                {
                    VariableExtractionFactory.ExtractVariables(elem, variables, Parms);
                }
            }
        }
 public static void TestExtraction(IEnumerable <string> templates, ExtractedVariable expectedVar)
 {
     TestExtraction(templates, new[] { expectedVar });
 }
Esempio n. 3
0
        private static void ExtractVar(IDictionary <string, ExtractedVariable> variables, AbstractConditionPart v, ExtractedVariable itVar)
        {
            var myVar = v as VariableConditionPart;

            if (myVar != null)
            {
                NoteVar(variables, myVar.VariableName, "0", false, itVar);
                return;
            }

            var opPart = v as OperationConditionPart;

            if (opPart != null)
            {
                var opPartLeft  = opPart.LeftSide as OperationConditionPart;
                var opPartRight = opPart.RightSide as OperationConditionPart;

                if (opPartLeft != null)
                {
                    ExtractVar(variables, opPartLeft, itVar);
                }

                if (opPartRight != null)
                {
                    ExtractVar(variables, opPartRight, itVar);
                }

                var opPartLeftV = opPart.LeftSide as VariableConditionPart;

                var opPartRightV = opPart.RightSide as VariableConditionPart;

                if (opPartLeftV != null && opPartRightV != null)
                {
                    NoteVar(variables, opPartLeftV.VariableName, "{" + opPartRightV.VariableName + "}", false, itVar);
                    NoteVar(variables, opPartRightV.VariableName, "{" + opPartLeftV.VariableName + "}", false, itVar);
                }
                else if (opPartLeftV != null)
                {
                    NoteVars(opPartLeftV, opPart.RightSide, variables, false, itVar);
                }
                else if (opPartRightV != null)
                {
                    NoteVars(opPartRightV, opPart.LeftSide, variables, false, itVar);
                }
            }
        }
 public static void TestExtraction(string template, ExtractedVariable expectedVar)
 {
     TestExtraction(new[] { template }, new[] { expectedVar });
 }