예제 #1
0
파일: IF.cs 프로젝트: mimfa/MiMFa.Framework
        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);
        }
예제 #2
0
 public REMOTE() : base()
 {
     timer.Interval = 1;
     timer.Tick    += (o, e) =>
     {
         if (content != Null)
         {
             string st = "";
             MCL.SetToResultDic(-9, st = MCL.Parse(content.ToString()));
             bool sen = false;
             int  trl = 0;
             while (!sen && trl < 15)
             {
                 try
                 { reciever.Send(st); sen = true; }
                 catch { trl++; }
             }
         }
         if (contentcallback != Null)
         {
             MCL.SetToResultDic(-91, MCL.Display.Done(contentcallback));
         }
         contentcallback = Null; content = Null;
     };
 }
예제 #3
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()))
            {
                throw new System.Exception("Not found any definitions");
            }
            string[] elements = definition.Split(',');
            elements = MiMFa_CollectionService.ExecuteInAllItems(elements, (s) => s.Trim());
            if (elements.Length < 2)
            {
                throw new System.Exception("Definition is not right");
            }
            string def = elements[0];
            object eno = MCL.Execute(elements[1]);

            return(Normalization(each(def, eno, cmd).ToArray()));
        }
예제 #4
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()));
        }
예제 #5
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));
        }
예제 #6
0
 public override object EXECUTE(params object[] po)
 {
     if (_print)
     {
         return(MiMFa_IOService.FileToString(MCL.Address.Constructor));
     }
     else if (_delete && _all)
     {
         MiMFa_IOService.ClearFileContent(MCL.Address.Constructor);
     }
     else if (po != null && po.Length > 0)
     {
         string cmd = MCL.CrudeText(Normalization(po[0].ToString()).Replace("  ", " ")) + ";";
         if (_delete)
         {
             MiMFa_IOService.StringRemoveFromFile(MCL.Address.Constructor, cmd + ";");
         }
         else
         {
             MiMFa_IOService.StringNewLineAppendFile(MCL.Address.Constructor, cmd);
             MCL.Parse(cmd);
         }
     }
     return(Null);
 }
예제 #7
0
 public override object execute(object obj, int index, int length)
 {
     if (obj == null)
     {
         return(Null);
     }
     return(MCL.Parser(obj.ToString()));
 }
예제 #8
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);
        }
예제 #9
0
 public virtual object delete(params object[] po)
 {
     foreach (var item in po)
     {
         MCL.RemoveVar(item.ToString());
     }
     return(null);
 }
예제 #10
0
 private void Wc_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
 {
     if (e.Cancelled)
     {
         MCL.SetToResultDic(-99, e.Error.Message);
     }
     else
     {
         MCL.SetToResultDic(-90, MiMFa_LanguageReader.GetText("Download Completed"));
     }
 }
예제 #11
0
        public override object EXECUTE(params object[] po)
        {
            if (po == null || po.Length == 0)
            {
                return(Null);
            }
            string str = po[0].ToString();

            str = MCL.CrudeText(str);
            return(print(str.Split(',')));
        }
예제 #12
0
 public TCP() : base()
 {
     timer.Tick += (o, e) =>
     {
         if (content != Null)
         {
             MCL.SetToResultDic(-1, MCL.Display.Done(content));
         }
         content = Null;
     };
     timer.Interval = 1;
 }
예제 #13
0
 public override object EXECUTE(params object[] po)
 {
     if (_all && _print)
     {
         return(printall(po));
     }
     else if (_all && _delete)
     {
         return(deleteall(po));
     }
     else if (_delete)
     {
         return(delete(po));
     }
     else
     {
         string s = po[0].ToString();
         MiMFa_CommandLanguage.CommandType type = MCL.TypeDetector(ref s, null).Key;
         bool allow =
             type != MiMFa_CommandLanguage.CommandType.Evaluatable &&
             type != MiMFa_CommandLanguage.CommandType.Property &&
             type != MiMFa_CommandLanguage.CommandType.Collection &&
             type != MiMFa_CommandLanguage.CommandType.Command &&
             type != MiMFa_CommandLanguage.CommandType.Comparable &&
             type != MiMFa_CommandLanguage.CommandType.String &&
             !MCL.IsSwitch(s) &&
             !MCL.IsSSwitch(s) &&
             type != MiMFa_CommandLanguage.CommandType.Function &&
             type != MiMFa_CommandLanguage.CommandType.MultiSlice &&
             !nonewcreate;
         if (_force ||
             (!s.Contains("=") &&
              !s.Contains(",") && allow))
         {
             MCL.AddVar(s, Null);
             return(Null);
         }
         if ((s.Contains("=") ||
              s.Contains(",")) && allow)
         {
             string[] stra = s.Split(',');
             _null = !_print;
             return(echo(stra));
         }
         else
         {
             throw new System.Exception("This name is not valid for variable");
         }
     }
 }
예제 #14
0
        public override object execute(object obj, int index, int length)
        {
            if (obj == null)
            {
                return(Null);
            }
            CommandBase ac = MCL.GetCommand(obj.ToString());

            if (ac == null)
            {
                return(Null);
            }
            return(ac.help());
        }
예제 #15
0
 public override object EXECUTE(params object[] po)
 {
     if (po != null && po.Length > 0)
     {
         var sa = MiMFa_StringService.FirstFindAndSplit(po[0].ToString(), ",");
         if (_open || o)
         {
             return(MCL.Compile(MiMFa_IOService.FileToString(PATH.getpath(MCL.Compile(sa[0])))));
         }
         else if (_save || s || sa.Length == 2)
         {
             MiMFa_IOService.StringToFile(MCL.Parse(PATH.getpath(sa[0] + extention)), MCL.CrudeText(sa[1]));
         }
     }
     return(Null);
 }
예제 #16
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);
        }
예제 #17
0
        public override object EXECUTE(params object[] po)
        {
            string[] sa = MiMFa_StringService.FirstFindAndSplit(MCL.CrudeText(po[0].ToString()).Trim(), MCLTools.SignPointer);

            string expr = sa.First().Trim().ToLower();

            expr = MCL.DownLayer(expr);
            expr = expr.Replace(MiMFa_CommandLanguage.StartSignStrongString, "").Replace(MiMFa_CommandLanguage.EndSignStrongString, "")
                   .Replace(MiMFa_CommandLanguage.StartSignString, "").Replace(MiMFa_CommandLanguage.EndSignString, "");
            string un = MCL.CrudeText(expr);

            expr = sa.Last().Trim().ToLower();
            expr = MCL.DownLayer(expr);
            expr = expr.Replace(MiMFa_CommandLanguage.StartSignStrongString, "").Replace(MiMFa_CommandLanguage.EndSignStrongString, "")
                   .Replace(MiMFa_CommandLanguage.StartSignString, "").Replace(MiMFa_CommandLanguage.EndSignString, "");
            string cmd = MCL.CrudeText(expr);

            MCL.PutsDic.AddOrSet(un, cmd);
            return(Null);
        }
예제 #18
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);
 }
예제 #19
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);
 }
예제 #20
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);
        }
예제 #21
0
 public override object EXECUTE(params object[] po)
 {
     if (po != null && po.Length > 0)
     {
         string name = po[0].ToString();
         name = MCLTools.ParenthesisPU.Parse(name);
         string[] stra = MiMFa_StringService.FirstFindAndSplit(name, MCLTools.StartSignParenthesis);
         Function fu   = new Function();
         fu.Name   = stra[0];
         fu.Access = MCL.EnvironmentAccess;
         stra      = MiMFa_StringService.FirstFindAndSplit(stra[1], MCLTools.EndSignParenthesis);
         fu.Inputs = MiMFa_CollectionService.ExecuteInAllItems(stra[0].Split(MCLTools.SplitSign), (os) => MCL.CrudeText(os).Trim());
         if (fu.Inputs.Length == 1 && string.IsNullOrEmpty(fu.Inputs[0]))
         {
             fu.Inputs = new string[] { }
         }
         ;
         fu.Commands = MCL.CrudeText(stra[1]).Trim();
         MiMFa_CommandLanguage.FunctionsList.Add(fu);
         return(fu);
     }
     return(Null);
 }
예제 #22
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()));
        }
예제 #23
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);
        }
예제 #24
0
 private bool Start(params object[] po)
 {
     timer.Enabled = !_stop;
     if (_new || ipaddress == null || reciever == null || sender == null)
     {
         if (_password)
         {
             string[] stra = po[0].ToString().Split(',');
             setpassword("", stra.Last().Trim());
             if (stra.Length > 1)
             {
                 po[0] = MiMFa_CollectionService.GetAllItems(MiMFa_CollectionService.GetPart(stra, 0, stra.Length - 1), ",", 0);
             }
             else
             {
                 po[0] = "";
             }
         }
         ipaddress = IPAddress.Any;
         if (_all)
         {
             ipaddress = IPAddress.Any;
         }
         else
         {
             try
             {
                 ipaddress = IPAddress.Parse(MCL.Parse(po[0] + ""));
             }
             catch { }
         }
         reciever                 = new MiMFa_Receiver();
         sender                   = new MiMFa_Sender();
         sender.Port              = reciever.Port = port;
         sender.BufferSize        = reciever.BufferSize = buffer;
         reciever.EndReceiveData += (b, ip, i) =>
         {
             object o = MiMFa_IOService.Deserialize(b);
             if (string.IsNullOrEmpty(password))
             {
                 content = o;
             }
             else if (!MiMFa_CollectionService.ExistIn(remotedic, ip.Address))
             {
                 remotedic.Add(ip.Address, crypt.GetHashString(o.ToString()));
             }
             else if (remotedic[ip.Address] == password)
             {
                 content = o;
             }
             else
             {
                 remotedic[ip.Address] = crypt.GetHashString(o.ToString());
             }
         };
         reciever.SendCallBackData += (o, ip, i) =>
         {
             contentcallback = o;
         };
         reciever.Start(ipaddress);
         if (ipaddress != IPAddress.Any)
         {
             sender.InterlocutorIP = ipaddress;
         }
         return(false);
     }
     if (ipaddress != IPAddress.Any)
     {
         sender.InterlocutorIP = ipaddress;
     }
     else if (sender.InterlocutorIP == null || _ip || i)
     {
         try
         {
             string[] stra = po[0].ToString().Split(',');
             ipaddress = sender.InterlocutorIP = IPAddress.Parse(stra.First().Trim());
             if (stra.Length > 1)
             {
                 po[0] = MiMFa_CollectionService.GetAllItems(stra, ",", 1);
             }
             else
             {
                 po[0] = "";
             }
         }
         catch { }
     }
     sender.Port       = reciever.Port = port;
     sender.BufferSize = reciever.BufferSize = buffer;
     sender.Run        = reciever.Run = !_stop;
     return(true);
 }
예제 #25
0
 public override object EXECUTE(params object[] po)
 {
     MCL.Start(MCL.DisplayType);
     return(Null);
 }
예제 #26
0
 private void Wc_DownloadProgressChanged(object sender, System.Net.DownloadProgressChangedEventArgs e)
 {
     MCL.SetToResultDic(-97, "|" + e.ProgressPercentage + "%| " + e.BytesReceived + " Bytes from " + e.TotalBytesToReceive);
 }