public override void Serialize(TextWriter tw) { foreach (var elem in Element.Elements) { TemplateSerializationFactory.Serialize(tw, elem, Variables, Arrays, Parms); } }
public override void Serialize(TextWriter tw) { var varPart = Element.Variable; var min = int.Parse(ConditionSerializer.Serialize(Element.Minimum, Variables, Arrays)); var max = int.Parse(ConditionSerializer.Serialize(Element.Maximum, Variables, Arrays)); if (!Element.InludeMaximum) { max--; } var vars = new Dictionary <string, string>(Variables) { { varPart.VariableName, null } }; for (int i = min; i <= max; ++i) { string value = i.ToString(); vars[varPart.VariableName] = value; foreach (var elem in Element.Elements) { TemplateSerializationFactory.Serialize(tw, elem, vars, Arrays, Parms); } } }
public override void Serialize(TextWriter tw) { if (ConditionSerializer.Serialize(Element.Condition, new Dictionary <string, string>(Variables), new Dictionary <string, IEnumerable <string> >(Arrays)) == true.ToString()) { foreach (var elem in Element.ConditionTrueElements) { TemplateSerializationFactory.Serialize(tw, elem, Variables, Arrays, Parms); } return; } if (Element.ConditionFalseElements != null) { foreach (var elem in Element.ConditionFalseElements) { TemplateSerializationFactory.Serialize(tw, elem, Variables, Arrays, Parms); } } }
public override void Serialize(TextWriter tw) { var varPart = Element.EnumerationCondition as VariableConditionPart; if (varPart != null) { SerializeVarPart(tw, varPart); } var opPart = Element.EnumerationCondition as OperationConditionPart; if (opPart != null && opPart.Operator == ConditionPartOperatorEnum.In && opPart.LeftSide is VariableConditionPart) { var vars = new Dictionary <string, string>(Variables); var enumerationVariable = ((VariableConditionPart)opPart.LeftSide).VariableName; vars.Add(enumerationVariable, null); IEnumerable <string> values = new string[0]; if (opPart.RightSide is GroupedConditionPart) { values = ((GroupedConditionPart)opPart.RightSide).Values.Select(val => ConditionSerializer.Serialize(val, Variables, Arrays)); } else if (opPart.RightSide is VariableConditionPart) { string key = ((VariableConditionPart)opPart.RightSide).VariableName; if (Arrays.ContainsKey(key)) { values = Arrays[key]; } } foreach (var value in values) { vars[enumerationVariable] = value; foreach (var elem in Element.Elements) { TemplateSerializationFactory.Serialize(tw, elem, vars, Arrays, Parms); } } } }
public override void Serialize(TextWriter tw) { var sw = new StringWriter(); foreach (var elem in Element.Elements) { TemplateSerializationFactory.Serialize(sw, elem, Variables, Arrays, Parms); } string result = sw.ToString(); string[] lines = result.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Select(CleanLine).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray(); if (Element.IsArray) { Arrays[Element.Variable.VariableName] = lines; } else { Variables[Element.Variable.VariableName] = string.Join(Environment.NewLine, lines); } }
private void SerializeVarPart(TextWriter tw, VariableConditionPart varPart) { string enumerationVariable = varPart.VariableName; var arrs = new Dictionary <string, IEnumerable <string> >(Arrays); arrs.Remove(enumerationVariable); var vars = new Dictionary <string, string>(Variables) { { enumerationVariable, null } }; foreach (var value in Arrays[enumerationVariable]) { vars[enumerationVariable] = value; foreach (var elem in Element.Elements) { TemplateSerializationFactory.Serialize(tw, elem, vars, arrs, Parms); } } }