Ejemplo n.º 1
0
        private int WriteNode(List<string> lines, int nodeNum, Node node)
        {
            nodeNum++;
            String line = String.Empty;
            line = String.Format("{0} {1} {2} {3} {4}", node.Id, nodeNum*1000, node.ScriptString,
                                 node.ShuffleAnswers ? "0" : "1", node.Answers != null && node.Answers.Count > 0 ? "#" : "@");
            lines.Add(line);
            if (node.Answers != null && node.Answers.Count > 0)
            {
                int ansNum = 0;
                for (int i = 0; i < node.Answers.Count; i++)
                {
                    line = String.Format("{0} {1}", node.Answers[i].ToNode, nodeNum*1000 + (++ansNum*10));

                    var dynamics = new List<Dynamic>(node.Answers[i].Demands.ToArray());
                    dynamics.AddRange(node.Answers[i].Results.ToArray());

                    foreach (Dynamic dyn in dynamics)
                    {
                        WriteDynamicLine(ref line, dyn);
                    }

                    if (i == node.Answers.Count - 1)
                        line += " @";
                    else
                        line += " #";
                    lines.Add(line);
                }
            }
            return nodeNum;
        }
Ejemplo n.º 2
0
        private Node ParseNode(Regex langEndLine, IEnumerable<string> languages, string[] parts, ref int nodeNum)
        {
            nodeNum++;
            var node = new Node {Id = Int32.Parse(parts[0]), ScriptString = parts[2], ShuffleAnswers = (parts[3] != "1")};

            foreach (String lang in languages)
            {
                Regex langStartLine = new Regex("^\\[" + lang + "\\]");
                node.Text[lang] = _textStrings.GetMSGValue(nodeNum*1000, langStartLine, langEndLine);
            }
            return node;
        }