Example #1
0
        public virtual MiMFa_List <object> each(string def, dynamic collection, string cmd)
        {
            MiMFa_List <object> result = new MiMFa_List <object>();

            MCL.PushAccess();
            MCL.Parse(def);
            string name = def.Trim().Split(' ').Last().Trim();

            foreach (var item in collection)
            {
                if (breakrun-- != 0)
                {
                    break;
                }
                MCL.SetVar(name, item);
                object str = echo(cmd);
                curr = str;
                result.Add(str);
            }
            MCL.PopRemoveAccess();
            return(result);
        }
Example #2
0
        public override object EXECUTE(params object[] po)
        {
            string cmd = po[0].ToString().Trim();

            cmd = MCLTools.ParenthesisPU.Parse(cmd);
            string definition = MiMFa_StringService.GetFirstWordBetween(cmd, "(", ")", false);

            if (definition != null)
            {
                cmd = MiMFa_StringService.FirstFindAndReplace(cmd, "(" + definition + ")", "");
            }
            else
            {
                definition = "";
            }
            if (string.IsNullOrEmpty(definition.Trim()))
            {
                definition = "";
            }
            string[] elements = definition.Split(',');
            elements = MiMFa_CollectionService.ExecuteInAllItems(elements, (s) => s.Trim());
            string def       = (elements.Length == 3) ? elements[0] : "";
            string condition = (elements.Length == 3 && !string.IsNullOrEmpty(elements[1])) ? elements[1] : "true";
            string after     = (elements.Length == 3) ? elements[2] : "";

            MCL.PushAccess();
            MCL.Parse(def);
            MiMFa_List <object> result = new MiMFa_List <object>();

            for (; breakrun-- == 0 && Convert.ToBoolean(MCL.Parser(condition)); MCL.Parse(after))
            {
                result.Add(echo(cmd));
            }
            MCL.PopRemoveAccess();
            return(Normalization(result.ToArray()));
        }