public static string GetRepresentation(SequenceMaker maker, List<string> sequences, Sequence sequence)
        {
            string result = "";

            sequence.Argument1 = PrepareArgument(maker, sequences, sequence.Argument1);
            sequence.Argument2 = PrepareArgument(maker, sequences, sequence.Argument2);

            if (sequence.Name == "Flow")
            {
                result = GetFlowRepresentation(sequence.Argument1, sequence.Argument2);
            }
            else if (sequence.Name == "Dec")
            {
                sequence.Argument3 = PrepareArgument(maker, sequences, sequence.Argument3);
                result = GetDecisionRepresentation(sequence.Argument1, sequence.Argument2, sequence.Argument3);
            }
            else if (sequence.Name == "Fork")
            {
                sequence.Argument3 = PrepareArgument(maker, sequences, sequence.Argument3);
                result = GetForkRepresentation(sequence.Argument1, sequence.Argument2, sequence.Argument3);
            }
            else if (sequence.Name == "Loop")
            {
                sequence.Argument3 = PrepareArgument(maker, sequences, sequence.Argument3);
                result = GetLoopRepresentation(sequence.Argument1, sequence.Argument2, sequence.Argument3);
            }

            return result;
        }
Example #2
0
        public static Sequence GetSequenceFromString(string stringToParse)
        {
            Sequence seq = new Sequence();

            string sequence = stringToParse.Replace(" ", "");
            int braceIndex = sequence.IndexOf("(");

            //Console.WriteLine("Try to parse: " + stringToParse);

            seq.Name = sequence.Substring(0, braceIndex);

            if (seq.Name == "Flow")
            {
                int comaIndex = sequence.IndexOf(",");
                string arg1 = sequence.Substring(braceIndex + 1, sequence.Length - comaIndex - 2);

                int bIndex = arg1.IndexOf("(");

                if (comaIndex > bIndex)
                {
                    comaIndex = sequence.LastIndexOf(",");
                }

                seq.Argument1 = sequence.Substring(braceIndex + 1, comaIndex - braceIndex - 1);
                seq.Argument2 = sequence.Substring(comaIndex + 1, sequence.Length - comaIndex - 2);
            }
            else
            {
                int comaIndex1 = sequence.IndexOf(",");

                string arg2 = sequence.Substring(comaIndex1 + 1, sequence.Length - comaIndex1 - 1);
                int comaIndex2 = arg2.IndexOf(",");

                seq.Argument1 = sequence.Substring(braceIndex + 1, comaIndex1 - braceIndex - 1);
                seq.Argument2 = arg2.Substring(0, comaIndex2);
                seq.Argument3 = arg2.Substring(comaIndex2 + 1, arg2.Length - comaIndex2 - 2);
            }
            //seq.Describe();

            return seq;
        }