Example #1
0
        public virtual object run(object[] po)
        {
            List <string> ls  = new List <string>();
            object        obj = null;

            if (_args)
            {
                processrun(po[0].ToString().Trim(), MiMFa_CollectionService.GetAllItems(MiMFa_CollectionService.GetPart(po, 1)));
            }
            else
            {
                foreach (var item in po)
                {
                    try
                    {
                        obj = processrun(item.ToString().Trim());
                        ls.Add(obj.ToString());
                    }
                    catch (System.Exception ex) { if (_error)
                                                  {
                                                      ls.Add(ex.Message);
                                                  }
                    }
                }
            }
            if (_print)
            {
                return(echo(ls.ToArray()));
            }
            else
            {
                return(Null);
            }
        }
Example #2
0
 public virtual object Create(string attachment = "")
 {
     if (ColumnDic == null)
     {
         return(null);
     }
     Change = true;
     return(MSQL.Execute(string.Join("", CREATE_QUERY, " (", MiMFa_CollectionService.GetAllItems(ColumnDic, " ", " , "), ") ", attachment, ";"), MiMFa_ExecuteType.ExecuteNonQuery));
 }
Example #3
0
        public override string ToString()
        {
            switch (Display)
            {
            case MiMFa_KeyValuePair <T, F> .DisplayMember.Key:
                return(MiMFa_CollectionService.GetAllKeysItem(this, SplitSign));

            case MiMFa_KeyValuePair <T, F> .DisplayMember.Value:
                return(MiMFa_CollectionService.GetAllValuesItem(this, SplitSign));

            default:
                return(MiMFa_CollectionService.GetAllItems(this, MiddleSign, SplitSign));
            }
        }
Example #4
0
        public static List <string> NamesListCompletion(List <string> namesList)
        {
            List <string>         result = new List <string>();
            List <List <string> > com    = new List <List <string> >();

            string[] splittor = new string[] { " ", "." };
            try
            {
                com = (from name in namesList
                       where Statement.And((from part in name.Split(splittor, StringSplitOptions.RemoveEmptyEntries)
                                            select part.Length > 1).ToArray())
                       select name.Split(splittor, StringSplitOptions.RemoveEmptyEntries).ToList()).ToList();
            }
            catch { }
            foreach (var item in namesList)
            {
                string[] arr = item.Split(splittor, StringSplitOptions.RemoveEmptyEntries);
                try
                {
                    result.Add(MiMFa_CollectionService.GetAllItems(com.Find((name) =>
                    {
                        if (arr.Length != name.Count)
                        {
                            return(false);
                        }
                        for (int i = 0; i < name.Count; i++)
                        {
                            if (!name[i].StartsWith(arr[i]))
                            {
                                return(false);
                            }
                        }
                        return(true);
                    }), " "));
                } catch { result.Add(item); }
            }

            return(result);
        }
Example #5
0
 public override string ToString()
 {
     return(MiMFa_CollectionService.GetAllItems(Items, SplitSign, 0));
 }
Example #6
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);
 }
Example #7
0
        public string GetValueFromXML(HTMLElementPatern elementPatern, MiMFa_XMLElement elem)
        {
            switch (elementPatern.Usage)
            {
            case MiMFa_Usage.Null:
            case MiMFa_Usage.Get:
                switch (elementPatern.ElementItems)
                {
                case MiMFa_XMLElementItems.Null:
                case MiMFa_XMLElementItems.ThisContent:
                    return(elem.OuterText);

                case MiMFa_XMLElementItems.ThisTag:
                    return(elem.Outer);

                case MiMFa_XMLElementItems.ThisAttribute:
                    return(elem.GetAttribute(elementPatern.AttributeName));

                case MiMFa_XMLElementItems.ChildContent:
                    return((elem.GetFirstChildElementByTagName(elementPatern.ChildName) ?? new MiMFa_XMLElement(-1, "", "", "")).OuterText);

                case MiMFa_XMLElementItems.ChildTag:
                    return((elem.GetFirstChildElementByTagName(elementPatern.ChildName) ?? new MiMFa_XMLElement(-1, "", "", "")).Outer);

                case MiMFa_XMLElementItems.ChildAttribute:
                    return((elem.GetFirstChildElementByTagName(elementPatern.ChildName) ?? new MiMFa_XMLElement(-1, "", "", "")).GetAttribute(elementPatern.AttributeName));

                case MiMFa_XMLElementItems.ChildrenContent:
                    return((new MiMFa_XMLElement(-1, "", "", "")
                    {
                        Children = elem.GetChildrenElementsByTagName(elementPatern.ChildName)
                    }).OuterText);

                case MiMFa_XMLElementItems.ChildrenTag:
                    return((new MiMFa_XMLElement(-1, "", "", "")
                    {
                        Children = elem.GetChildrenElementsByTagName(elementPatern.ChildName)
                    }).Outer);

                case MiMFa_XMLElementItems.ChildrenAttribute:
                    return(MiMFa_CollectionService.GetAllItems((new MiMFa_XMLElement(-1, "", "", "")
                    {
                        Children = elem.GetChildrenElementsByTagName(elementPatern.ChildName)
                    }).GetChildAttributes(elementPatern.AttributeName), "¶"));
                }
                break;

            case MiMFa_Usage.Set:
                string str = elem.GetAttribute("href");
                if (string.IsNullOrWhiteSpace(str))
                {
                    str = elem.GetAttribute("src");
                }
                if (string.IsNullOrWhiteSpace(str))
                {
                    str = elem.GetAttribute("url");
                }
                if (string.IsNullOrWhiteSpace(str))
                {
                    str = elem.InnerText;
                }
                if (!string.IsNullOrWhiteSpace(str))
                {
                    if (Uri.IsWellFormedUriString(str, UriKind.Relative))
                    {
                        str = MiMFa_Internet.GetBaseWebURL(fetch_url) + (str.StartsWith("/") ? "" : "/") + str;
                    }
                }
                else
                {
                    str = elem.OuterText;
                }
                return(str);
            }
            return(" ");
        }
Example #8
0
 public override object execute(object obj, int index, int length)
 {
     if (obj is Function)
     {
         Function f       = (Function)obj;
         string   path    = MCL.Address.BaseFunctionDirectory + f.Name + "(" + f.Inputs.Length + ")" + MCL.Address.FunctionExtension;
         string   content = f.Access.Status.ToString().ToLower() + " function " + f.Name + "(" + MiMFa_CollectionService.GetAllItems(f.Inputs, ",") + ")" + Environment.NewLine + f.Commands + ";";
         MiMFa_IOService.StringToFullFile(path, content);
     }
     else
     {
         string path = MiMFa_Path.CreateValidPathName(MCL.Address.BaseOtherDirectory, "out", MCL.Address.BinaryExtension, false);
         MiMFa_IOService.SaveSerializeFile(path, obj);
     }
     return(obj);
 }
Example #9
0
        public static MiMFa_Percent ContentLikePerCent(string str1, string str2)
        {
            if (string.IsNullOrEmpty(str1) && string.IsNullOrEmpty(str2))
            {
                return(new MiMFa_Percent(0, 0, 100));
            }
            if (string.IsNullOrEmpty(str1) && !string.IsNullOrEmpty(str2))
            {
                return(new MiMFa_Percent(-100, 0, 0));
            }
            if (!string.IsNullOrEmpty(str1) && string.IsNullOrEmpty(str2))
            {
                return(new MiMFa_Percent(0, -100, 0));
            }
            MiMFa_Percent percent;

            if (((percent = ContentComparePerCent(str1, str2))) > 70)
            {
                return(percent);
            }
            List <string> lst1  = GetKeywords(str1).ValueList;
            List <string> lst2  = GetKeywords(str2).ValueList;
            List <string> nlst1 = str1.Split(new string[] { "   ", "  ", " ", "&", ",", "،", "'", "`", ":", ";", "؛", ".", "?", "؟", "!" }, StringSplitOptions.RemoveEmptyEntries).ToList();
            List <string> nlst2 = str2.Split(new string[] { "   ", "  ", " ", "&", ",", "،", "'", "`", ":", ";", "؛", ".", "?", "؟", "!" }, StringSplitOptions.RemoveEmptyEntries).ToList();

            if (lst1.Count < 2 * nlst1.Count / 3 || lst2.Count < 2 * nlst2.Count / 3)
            {
                lst1 = nlst1;
                lst2 = nlst2;
            }
            else
            {
                return(ContentComparePerCent(MiMFa_CollectionService.GetAllItems(lst1, " "), MiMFa_CollectionService.GetAllItems(lst2, " ")));
            }
            if (lst1.Count < 2 && lst2.Count < 2)
            {
                return(percent.Normalization());
            }
            if ((lst1.Count >= 2 * lst2.Count) || (lst2.Count >= 2 * lst1.Count))
            {
                return(new MiMFa_Percent(-100, 0, 0));
            }
            decimal unit = Convert.ToDecimal(93) / ((lst2.Count + lst1.Count) / 2);

            percent = new MiMFa_Percent(-7, 0, 0);
            MiMFa_Percent newf     = new MiMFa_Percent(0, 0, 0);
            MiMFa_Percent maxf     = new MiMFa_Percent(0, 0, 0);
            int           maxindex = -1;

            for (int i = 0; i < lst1.Count; i++)
            {
                maxf = new MiMFa_Percent(0, 0, 0);
                for (int j = 0; j < lst2.Count; j++)
                {
                    newf = ContentComparePerCent(lst1[i], lst2[j]);
                    if (newf > maxf)
                    {
                        maxf.SetValue(newf);
                        maxindex = j;
                    }
                }
                if (maxf > 50)
                {
                    if (maxindex > -1)
                    {
                        lst2.RemoveAt(maxindex);
                    }
                    percent.AddValue((maxf / 100) * unit);
                }
                else
                {
                    percent.AddValue(-unit);
                }
            }
            return(percent.Normalization());
        }