Esempio n. 1
0
        public static string Convert(Function input_function)
        {
            var function = input_function.Clone() as Function;

            if (function.Blocks.Count == 0)
            {
                return("No block to visualize");
            }

            var errors = FunctionConverter.Validator(function);

            if (errors.Count() > 0)
            {
                return(string.Join("\n", errors));
            }

            var output = new List <string>();
            var indent = 0;

            foreach (Base block in function.Blocks)
            {
                output.Add(BlockConverter.ConvertBlock(block, function, ref indent));
                output.Add(string.Empty);
            }


            output.Insert(1, "\tconst factory = getFactory();");
            output.Insert(1, "\tconst me = getCurrentParticipant();");


            return(string.Join("\n", output));
        }
Esempio n. 2
0
        private static string Convert(MyAssign input, Function f, ref int i)
        {
            var variable = ConvertOutput(input.Variable.Output);
            var value    = ConvertOutput(input.Value.Output);

            if (input.Value.Value.Alias == string.Empty)
            {
                value = string.Format("factory.NewResource('namespace','{0}');", input.Value.Value.ObjectName);
            }
            if (input.Value.Value.Alias == "#currentUser")
            {
                value = "me.getIdentifier()";
            }
            if (input.Value.Value.Alias == "#currentDateTime")
            {
                value = "tx.timestamp";
            }


            return(string.Format("{0}{1} = {2};", BlockConverter.Indent(i), variable, value));
        }
Esempio n. 3
0
 private static string Convert(MyLog input, Function f, ref int i)
 {
     return(string.Format("{0}console.log('[{1}] {2}');", BlockConverter.Indent(i), f.Name, ConvertText(input.Text)));
 }
Esempio n. 4
0
 private static string Convert(MyError input, Function f, ref int i)
 {
     return(string.Format("{0}throw new Error('[{1}] {2}');", BlockConverter.Indent(i), f.Name, ConvertText(input.Text)));
 }
Esempio n. 5
0
 private static string Convert(MyEnd input, Function f, ref int i)
 {
     return(string.Format("{0}}}", BlockConverter.Indent(--i)));
 }
Esempio n. 6
0
 private static string Convert(MyElse input, Function f, ref int i)
 {
     return(string.Format("{0}}}else {{", BlockConverter.Indent(i - 1)));
 }