public bool AddDialogVariableConditions(DialogVariableConditions variableConditions)
        {
            bool variablesChanged           = false;
            var  conditionsGroupsByVariable = variableConditions.VariableConditions.Where(condition => condition.Comparison == ConditionComparison.Equals).GroupBy(condition => condition.Variable);

            foreach (var conditionGroup in conditionsGroupsByVariable)
            {
                var            variable       = conditionGroup.Key;
                IList <string> previousValues = null;
                if (VariablesValues.ContainsKey(variable))
                {
                    previousValues = VariablesValues[variable];
                }
                IList <string> newValues = null;
                if (conditionGroup.Count() > 1 && variableConditions.Operator == ConditionOperator.Or)
                {
                    newValues = conditionGroup.Select(condition => condition.Value).ToList();
                }
                else
                {
                    newValues = new List <string>(1);
                    newValues.Add(conditionGroup.First().Value);
                }
                VariablesValues[variable] = newValues;
                if (previousValues == null ||
                    previousValues.Count != newValues.Count ||
                    previousValues.Intersect(newValues).Count() < previousValues.Count)
                {
                    variablesChanged = true;
                }
            }
            return(variablesChanged);
        }
Esempio n. 2
0
        private static void WriteDialogVariableConditions(XmlWriter xw, DialogVariableConditions childNode)
        {
            xw.WriteStartElement("If");
            string expression = childNode.Expression;

            xw.WriteAttributeString("Expr", expression);
            if (childNode.VariableValuesRestriction != null)
            {
                xw.WriteAttributeString("RestrictValuesAllowedByFederationGroupIn", childNode.VariableValuesRestriction.VariableName);
            }
            WriteDialogNodeProperties(xw, childNode);
            WriteChildrenNodes(xw, childNode);
            xw.WriteEndElement();
        }