Beispiel #1
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;
     };
 }
Beispiel #2
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);
 }
Beispiel #3
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 #4
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);
 }
Beispiel #5
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);
        }
Beispiel #6
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 #7
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);
 }