Beispiel #1
0
        public static dynamic INVOKE(Function func, params object[] inputs)
        {
            if (!Accessibility.IsAccess(MCL.EnvironmentAccess, func.Access))
            {
                throw new MethodAccessException("You not access to this function");
            }
            if (inputs == null)
            {
                inputs = new object[0];
            }
            string nam    = nameof(VARIABLE).ToLower();
            int    length = Math.Min(func.Inputs.Length, inputs.Length);

            for (int i = 0; i < func.Inputs.Length; i++)
            {
                if (func.Inputs[i].ToLower().StartsWith(nam))
                {
                    MCL.Parse(func.Inputs[i]);
                    if (inputs.Length > i)
                    {
                        MCL.SetVar(func.Inputs[i].Substring(nam.Length).Split('=')[0].Trim(), inputs[i]);
                    }
                }
                else
                {
                    MCL.AddVar(func.Inputs[i], (inputs.Length > i) ? inputs[i] : Null);
                }
            }
            return(MCL.Parser(func.Commands));
        }
Beispiel #2
0
        public override object EXECUTE(params object[] po)
        {
            string cmd = po[0].ToString().Trim();

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

            if (cond != null)
            {
                cmd = MiMFa_StringService.FirstFindAndReplace(cmd, "(" + cond + ")", "");
            }
            else
            {
                cond = "";
            }
            if (string.IsNullOrEmpty(cond.Trim()))
            {
                throw new System.Exception("Not found any conditions");
            }
            cnd = Convert.ToBoolean(MCL.Parser(cond));
            if (cnd)
            {
                return(echo(cmd));
            }
            return(Null);
        }
Beispiel #3
0
        public override object EXECUTE(params object[] po)
        {
            string cmd = po[0].ToString().Trim();

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

            if (condition != null)
            {
                cmd = MiMFa_StringService.FirstFindAndReplace(cmd, "(" + condition + ")", "");
            }
            else
            {
                condition = "";
            }
            if (string.IsNullOrEmpty(condition.Trim()))
            {
                condition = "true";
            }
            MiMFa_List <object> result = new MiMFa_List <object>();

            while (breakrun-- == 0 && Convert.ToBoolean(MCL.Parser(condition)))
            {
                result.Add(echo(cmd));
            }
            return(Normalization(result.ToArray()));
        }
Beispiel #4
0
        public override object EXECUTE(params object[] po)
        {
            MCL.PushAccess(Collection.MiMFa_ProgrammingAccessibility.Public);
            object obj = MCL.Parser(po[0].ToString());

            MCL.PopAccess();
            return(obj);
        }
Beispiel #5
0
 public override object execute(object obj, int index, int length)
 {
     if (obj == null)
     {
         return(Null);
     }
     return(MCL.Parser(obj.ToString()));
 }
Beispiel #6
0
        public override object execute(object obj, int index, int length)
        {
            if (obj == null)
            {
                return(Null);
            }
            if (!_thread)
            {
                return(MCL.Parser(obj.ToString()));
            }
            Thread th = new Thread(() => MCL.Parser(obj.ToString()));

            th.IsBackground = _background;
            th.SetApartmentState(_mode?ApartmentState.MTA:ApartmentState.STA);
            th.Start();
            return(Null);
        }
Beispiel #7
0
 public override object execute(object obj, int index, int length)
 {
     if (obj == null)
     {
         return(Null);
     }
     string[] cas = obj.ToString().Split('=');
     if (cas.Length > 1)
     {
         curr = MCL.Parser(cas.Last());
     }
     else
     {
         curr = Null;
     }
     for (int i = 0; i < cas.Length - 1; i++)
     {
         MCL.AddVar(cas[i].Trim(), curr);
     }
     return(curr);
 }
Beispiel #8
0
 public static Function search(string name, int inputsnum = -1)
 {
     name = name.ToLower();
     try
     {
         Function f = MiMFa_CommandLanguage.FunctionsList.Find((v) => v.Name.ToLower() == name && v.Inputs.Length == inputsnum);
         if (f != null)
         {
             return(f);
         }
     }
     catch { }
     if (inputsnum > -1)
     {
         try
         {
             name = name + "(" + inputsnum + ")";
             string pat = MCL.Address.BaseFunctionDirectory + name + MCL.Address.FunctionExtension;
             if (File.Exists(pat))
             {
                 return((Function)MCL.Parser(MiMFa_IOService.FileToString(pat)));
             }
         }
         catch { }
     }
     else
     {
         try
         {
             string pat = (from v in General.MiMFa_Path.GetAllFiles(MCL.Address.BaseFunctionDirectory) where System.IO.Path.GetFileNameWithoutExtension(v).Split('(').First().ToLower() == name select v).First();
             if (File.Exists(pat))
             {
                 return((Function)MCL.Parser(MiMFa_IOService.FileToString(pat)));
             }
         }
         catch { }
     }
     return(null);
 }
Beispiel #9
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()));
        }
Beispiel #10
0
        public override object execute(object obj, int index, int length)
        {
            if (obj == null)
            {
                return(Null);
            }
            string str = (obj + "").ToLower();

            Model.MiMFa_List <object> objlist = new Model.MiMFa_List <object>();
            foreach (var item in str.Split(' ', ','))
            {
                switch (item.Trim())
                {
                case "inf":
                case "info":
                case "detail":
                case "details":
                    obj = MCL.Display.BreakLineSign
                          + "Name: " + MCL.Name + MCL.Display.BreakLineSign
                          + "Description: " + MCL.Description + MCL.Display.BreakLineSign
                          + "Version: " + MCL.Version + MCL.Display.BreakLineSign
                          + "Made By: MiMFa" + MCL.Display.BreakLineSign
                          + "Programmer: MuhaMad Fathi" + MCL.Display.BreakLineSign
                    ;
                    break;

                case "mac":
                case "mediaaccesscontrol":
                    obj = mac();
                    break;

                case "macs":
                case "mediaaccesscontrols":
                    obj = macs();
                    break;

                case "ips":
                case "ipas":
                case "InternetProtocols":
                case "InternetProtocoladdresses":
                    obj = ips();
                    break;

                case "ip":
                case "ipa":
                case "InternetProtocol":
                case "InternetProtocoladdresse":
                case "ipv4":
                case "ipav4":
                    obj = ipv4();
                    break;

                case "ipv6":
                case "ipav6":
                    obj = ipv6();
                    break;

                case "hn":
                case "cn":
                case "hostname":
                case "computername":
                    obj = hostname();
                    break;

                case "dt":
                case "date":
                    obj = date();
                    break;

                case "tm":
                case "time":
                    obj = time();
                    break;

                case "vs":
                case "vid":
                case "volumeserial":
                    obj = volumeserial();
                    break;

                case "vss":
                case "vids":
                case "volumesserial":
                case "volumeserials":
                    obj = volumesserial();
                    break;

                case "vp":
                case "vps":
                case "vsp":
                case "volumepartition":
                case "volumepartitions":
                case "volumespartition":
                    obj = volumespartitions();
                    break;

                case "vm":
                case "vsm":
                case "vms":
                case "volumesmodel":
                case "volumemodels":
                    obj = volumesmodel();
                    break;

                case "ps":
                case "pid":
                case "processorserial":
                    obj = processorserial();
                    break;

                case "pss":
                case "pids":
                case "processorsserial":
                case "processorserials":
                    obj = processorsserial();
                    break;

                case "ms":
                case "mbs":
                case "mid":
                case "mbid":
                case "motherboardserial":
                    obj = motherboardserial();
                    break;

                case "mss":
                case "mbss":
                case "mids":
                case "mbids":
                case "motherboardserials":
                case "motherboardsserial":
                    obj = motherboardsserial();
                    break;

                case "mp":
                case "mypath":
                    obj = Config.ApplicationPath;
                    break;

                case "ws":
                case "wsl":
                case "vl":
                case "vsl":
                case "var":
                case "vars":
                case "variable":
                case "variables":
                case "variableslist":
                case "workspacelist":
                    obj = MiMFa_CommandLanguage.WorkSpaceList;
                    break;

                case "put":
                case "puts":
                    obj = MCL.PutsDic;
                    break;

                case "hl":
                case "hsl":
                case "handlerslist":
                    obj = MiMFa_CommandLanguage.HandlersList;
                    break;

                case "cl":
                case "csl":
                case "commandslist":
                    obj = MiMFa_CommandLanguage.CommandsDic;
                    break;

                case "cb":
                case "tcb":
                case "clipboard":
                case "textclipboard":
                    obj = Clipboard.GetText();
                    break;

                case "icb":
                case "imageclipboard":
                    obj = Clipboard.GetImage();
                    break;

                case "dcb":
                case "docb":
                case "dataclipboard":
                case "dataobjectclipboard":
                    obj = Clipboard.GetDataObject();
                    break;

                case "fcb":
                case "fdcb":
                case "fileclipboard":
                case "filedropclipboard":
                    obj = Clipboard.GetFileDropList();
                    break;

                case "acb":
                case "ascb":
                case "audioclipboard":
                case "audiostreamclipboard":
                    obj = Clipboard.GetAudioStream();
                    break;

                case "ca":
                case "cfa":
                case "confa":
                case "conffa":
                case "configfileaddress":
                case "configurationaddress":
                case "configurationfileaddress":
                    obj = Config.ConfigFile;
                    break;

                case "confd":
                case "conffd":
                case "configfiledirectory":
                case "configurationdirectory":
                case "configurationfiledirectory":
                    obj = Config.ConfigurationDirectory;
                    break;

                case "conf":
                case "conff":
                case "configfile":
                case "configuration":
                case "configurationfile":
                    obj = Config.ConfigDic;
                    break;

                case "cd":
                case "dir":
                case "directory":
                case "currentdirectory":
                    obj = Config.ApplicationPath;
                    break;

                case "site":
                case "website":
                    obj = Config.ProductURL;
                    break;

                case "oh":
                case "help":
                case "onlinehelp":
                    obj = MCL.Parser(typeof(GO).Name + " \"" + Config.ProductHelpURL + "\";");
                    break;

                case "lang":
                case "language":
                    obj = MiMFa_LanguageReader.Language;
                    break;

                case "rd":
                case "rsd":
                case "rdic":
                case "rsdic":
                case "resultsdic":
                case "resultsdictionary":
                    obj = MCL.ResultsDic;
                    break;

                case "desc":
                case "description":
                    obj = MCL.Description;
                    break;

                case "ui":
                case "userinterface":
                    obj = MCL.UserInterface;
                    break;

                case "ver":
                case "version":
                    obj = MCL.Version;
                    break;

                case "0":
                    obj = MCL.root0;
                    break;

                case "1":
                    obj = MCL.root1;
                    break;

                case "2":
                    obj = MCL.root2;
                    break;

                default:
                    obj = SET.get(str);
                    break;
                }
                objlist.Add(obj);
            }
            if (!_concatwords && index < length - 1)
            {
                return(objlist + separatetext);
            }
            return(objlist);
        }