Example #1
0
        public static Color[] GetColorRenge(int length, MiMFa_SelectFromRange selectLow = MiMFa_SelectFromRange.Random, params Color[] colorRange)
        {
            Color[] arrc = new Color[length];
            int     j    = 0;

            for (int i = 0; i < length; i++)
            {
                if (colorRange.Length > j)
                {
                    arrc[i] = colorRange[j++];
                }
                else
                {
                    j       = 0;
                    arrc[i] = colorRange[j++];
                }
            }
            switch (selectLow)
            {
            case MiMFa_SelectFromRange.OrderBy:
                return(arrc);

            case MiMFa_SelectFromRange.Random:
                return(MiMFa_CollectionService.Shake(arrc));

            case MiMFa_SelectFromRange.Special:
                return(MiMFa_CollectionService.Shake(MiMFa_CollectionService.Shake(arrc)));

            default:
                return(arrc);
            }
        }
Example #2
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 #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()));
        }
Example #4
0
        public static List <MiMFa_XMLElement> GetTo(List <MiMFa_XMLElement> inThisList, MiMFa_XMLElement toThisElement)
        {
            int ind = -1;

            for (int i = 0; i < inThisList.Count; i++)
            {
                if (inThisList[i] <= toThisElement)
                {
                    ind = i;
                }
                else
                {
                    break;
                }
            }
            if (ind < 0)
            {
                return(new List <MiMFa_XMLElement>());
            }
            if (inThisList.Last() < toThisElement)
            {
                return(inThisList);
            }
            inThisList[ind].Children = GetTo(inThisList[ind].Children, toThisElement);
            return(MiMFa_CollectionService.GetPart(inThisList, 0, ind));
        }
Example #5
0
        public static List <MiMFa_XMLElement> GetFrom(List <MiMFa_XMLElement> inThisList, MiMFa_XMLElement fromThisElement)
        {
            int ind = -1;

            for (int i = 0; i < inThisList.Count; i++)
            {
                if (inThisList[i] <= fromThisElement)
                {
                    ind = i;
                }
                else
                {
                    break;
                }
            }
            if (ind < 0)
            {
                return(inThisList);
            }
            MiMFa_XMLElement m = inThisList.Last();

            if (!fromThisElement.ID.StartsWith(m.ID) && m < fromThisElement)
            {
                return(new List <MiMFa_XMLElement>());
            }
            inThisList[ind].Children = GetFrom(inThisList[ind].Children, fromThisElement);
            return(MiMFa_CollectionService.GetPart(inThisList, ind));
        }
Example #6
0
        public void ShowReport(Report report, MiMFa_SidePosition side = MiMFa_SidePosition.Null, int length = -1, bool withCompile = true)
        {
            if (ProgressBar != null)
            {
                ProgressBar.ProcessRun(1);
            }
            if (report.ObjectArray != null && report.ObjectArray.Length > 0)
            {
                if (length <= 0)
                {
                    if (!int.TryParse(tscb_NumberOFRecord.Text.ToString(), out length))
                    {
                        if (ProgressBar != null)
                        {
                            ProgressBar.ProcessRun(100);
                        }
                        return;
                    }
                }
                CurrentReport = new Report(report);
                switch (side)
                {
                case MiMFa_SidePosition.Right:
                    FromRecord = ToRecord + 1;
                    break;

                case MiMFa_SidePosition.Left:
                    FromRecord = FromRecord - length;
                    break;

                default:
                    break;
                }
                ToRecord = FromRecord + length - 1;
                if (FromRecord <= 0)
                {
                    FromRecord           = 0;
                    tsb_PageDown.Enabled = false;
                }
                else
                {
                    tsb_PageDown.Enabled = true;
                }
                if (ToRecord >= report.ObjectArray.Length || ToRecord < FromRecord)
                {
                    ToRecord           = report.ObjectArray.Length - 1;
                    tsb_PageUp.Enabled = false;
                }
                else
                {
                    tsb_PageUp.Enabled = true;
                }
                CurrentReport.ObjectArray = MiMFa_CollectionService.GetPart(CurrentReport.ObjectArray, FromRecord, ToRecord);
                Show(CurrentReport, withCompile);
                return;
            }
            Show(report, withCompile);
        }
Example #7
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 #8
0
 public static MethodInfo[] GetMethods(string methodName, Type type, bool caseSensivity = true)
 {
     MethodInfo[] methods = MiMFa_CollectionService.Concat(type.GetMethods(), type.GetRuntimeMethods().ToArray());
     if (caseSensivity)
     {
         return((from v in methods where v.Name == methodName select v).ToArray());
     }
     return((from v in methods where v.Name.ToUpper() == methodName.ToUpper() select v).ToArray());
 }
Example #9
0
        public List <T> Sort(List <T> inputList, ConstraintCollection constraints, params object[] conditions)
        {
            if (Shaked)
            {
                inputList = MiMFa_CollectionService.Shake(inputList);
            }
            List <KeyValuePair <T, InferenceCollection> > lold = new List <KeyValuePair <T, InferenceCollection> >();

            for (int i = 0; i < inputList.Count; i++)
            {
                lold.Add(new KeyValuePair <T, InferenceCollection>(inputList[i], new InferenceCollection()));
            }
            constraints.Sort();
            Constraint constraint = null;
            Type       t          = inputList.First().GetType();

            FieldInfo[]    fi = null;
            PropertyInfo[] pi = null;
            if (SendT)
            {
                for (int index = 0; index < constraints.Count; index++)
                {
                    for (int i = 0; i < inputList.Count; i++)
                    {
                        lold[i].Value.Add(constraints[index].Solver(inputList[i], conditions));
                    }
                }
            }
            else
            {
                for (int index = 0; index < constraints.Count; index++)
                {
                    constraint = constraints[index];
                    fi         = MiMFa_GetDetail.GetFields(inputList.First(), constraint.Name, false);
                    if (fi.Length > 0)
                    {
                        for (int i = 0; i < inputList.Count; i++)
                        {
                            lold[i].Value.Add(constraint.Solver(fi.First().GetValue(inputList[i]), conditions));
                        }
                    }
                    else
                    {
                        pi = MiMFa_GetDetail.GetProperties(inputList.First(), constraint.Name, false);
                        if (pi.Length > 0)
                        {
                            for (int i = 0; i < inputList.Count; i++)
                            {
                                lold[i].Value.Add(constraint.Solver(pi.First().GetValue(inputList[i]), conditions));
                            }
                        }
                    }
                }
            }
            lold = Sort(lold);
            return(AllowanceMember(lold));
        }
Example #10
0
        public virtual List <string> all(params object[] po)
        {
            List <string> ls = MiMFa_Path.GetAllFiles(MCL.Address.BaseDirectory, true);

            if (!_address)
            {
                ls = MiMFa_CollectionService.ExecuteInAllItems(ls, (s) => System.IO.Path.GetFileNameWithoutExtension(s));
            }
            return(ls);
        }
Example #11
0
        private char[] AllChars()
        {
            MiMFa_CharBank cb = new MiMFa_CharBank();

            return(MiMFa_CollectionService.Concat <char>(
                       cb.EnglishCharacters,
                       cb.FarsiCharacters,
                       cb.NumberCharacters,
                       cb.SignCharacters,
                       cb.SymbolCharacter));
        }
Example #12
0
        public static DataTable GET_SHAKED(DataTable Table)
        {
            int length = Table.Rows.Count;

            int[]     randindex = MiMFa_CollectionService.RandIndex(length);
            DataTable dt        = Table.Clone();

            for (int i = 0; i < length; i++)
            {
                dt.Rows.Add(Table.Rows[randindex[i]].ItemArray);
            }

            return(dt);
        }
Example #13
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 #14
0
        public override object EXECUTE(params object[] po)
        {
            MiMFa_Dictionary <object, object> lo = new MiMFa_Dictionary <object, object>();

            if (po != null)
            {
                for (int i = 0; i < po.Length; i++)
                {
                    KeyValuePair <object, object> kvp = MiMFa_Convert.ToKeyValuePair(po[i]);
                    lo.Add(kvp.Key, kvp.Value);
                }
                if (_sorted)
                {
                    lo = MiMFa_CollectionService.Sort(lo);
                }
            }
            return(lo);
        }
Example #15
0
        public static MiMFa_KeyWords <int, string> GetKeywords(string text)
        {
            MiMFa_KeyWords <int, string> kws = new MiMFa_KeyWords <int, string>();
            List <string> ls =
                MiMFa_CollectionService.Distinct(
                    MiMFa_CollectionService.ExecuteInAllItems(
                        MiMFa_CollectionService.Concat(
                            GetKeywordFromStruct(text),
                            GetKeywordFromAnd(text),
                            GetKeywordFromComma(text),
                            GetKeywordFromNumber(text),
                            GetKeywordFromEqual(text),
                            GetKeywordFromParenthesis(text),
                            GetKeywordFromBrackets(text),
                            GetKeywordFromBraces(text),
                            GetKeywordFromQuotation(text),
                            GetKeywordFromDoubleQuotation(text)
                            ), (t) => t
                        .Replace(".", " ")
                        .Replace(",", " ")
                        .Replace("،", " ")
                        .Replace("؛", " ")
                        .Replace(";", " ")
                        .Replace("?", " ")
                        .Replace("؟", " ")
                        .Replace("!", " ")
                        .Replace("'", " ")
                        .Replace("`", " ")
                        .Replace("\"", " ")
                        .Replace("(", " ")
                        .Replace(")", " ")
                        .Replace("[", " ")
                        .Replace("]", " ")
                        .Replace("{", " ")
                        .Replace("}", " ")
                        .Replace("&", " ")
                        .Trim()));

            foreach (var item in ls)
            {
                kws.Add(MiMFa_StringService.NumberOfWordsInText(text, item), item);
            }
            return(kws);
        }
Example #16
0
        private static string LikeLapSignC(string expr, params string[] signs)
        {
            string[] ca = { "&&", "||", "<=", ">=", "<", ">", "!==", "!=", "~==", "~=", "===", "==" };
            Func <string, string> func = (sign) =>
            {
                string[] sa = expr.Split(new string[] { sign }, StringSplitOptions.None);
                if (sa.Length <= 1)
                {
                    return(expr);
                }
                string[] arr = sa[0].Split(ca, StringSplitOptions.None);
                string   op1 = arr[arr.Length - 1];
                arr = sa[1].Split(ca, StringSplitOptions.None);
                string op2    = arr[0];
                string result = CompareString(op1, sign, op2).ToString();
                expr = expr.Replace(op1 + sign + op2, result);
                return(expr);
            };

            if (expr.Split(signs, StringSplitOptions.None).Length > 1)
            {
                do
                {
                    Dictionary <int, string> collection = new Dictionary <int, string>();
                    for (int i = 0; i < expr.Length; i++)
                    {
                        foreach (var item in signs)
                        {
                            if (expr.Substring(i).StartsWith(item))
                            {
                                collection.Add(i, item); break;
                            }
                        }
                    }
                    collection = MiMFa_CollectionService.Sort(collection, (d1, d2) => d1.Key < d2.Key);
                    foreach (var item in collection)
                    {
                        expr = func(item.Value);
                    }
                }while (expr.Split(signs, StringSplitOptions.RemoveEmptyEntries).Length > 1);
            }
            return(expr);
        }
Example #17
0
 public void ReceiveCallback(IAsyncResult ar)
 {
     try {
         //Socket handler;
         StartReceiveData(ar.AsyncState, Handler.RemoteEndPoint as IPEndPoint, 0);
         // Fetch a user-defined object that contains information
         // Received byte array
         byte[] data = (byte[])ar.AsyncState;
         // A Socket to handle remote host communication.
         // The number of bytes received.
         int bytesRead = Handler.EndReceive(ar);
         if (bytesRead > 0)
         {
             EndReceiveData(MiMFa_CollectionService.GetPart(data, 0, bytesRead - 1), Handler.RemoteEndPoint as IPEndPoint, bytesRead);
         }
     }
     catch (Exception ex)
     {
         ErrorReceiveData(ar, InterlocutorIPEndPoint, 0, ex);
     }
 }
Example #18
0
 public void ControlsSort(params Control[] childsByDecOrder)
 {
     try
     {
         Dictionary <string, int> diccon = GetDicClick(childsByDecOrder);
         List <int>     lin    = new List <int>();
         List <Control> lcon   = new List <Control>();
         List <int>     lout   = new List <int>();
         List <int>     lindex = new List <int>();
         Control        con_m  = null;
         StateOrders.Clear();
         foreach (var item in childsByDecOrder)
         {
             StateOrders.Add(item.Location, item.Size);
         }
         foreach (var item in diccon)
         {
             if ((con_m = MiMFa_ControlService.GetControlsByName(ControlsParent, item.Key)) != null)
             {
                 lcon.Add(con_m);
                 lin.Add(item.Value);
             }
         }
         MiMFa_CollectionService.Sort(lin, out lout, out lindex);
         lindex.Reverse();
         int index = 0;
         foreach (var item in StateOrders)
         {
             try
             {
                 lcon[lindex[index]].Size     = item.Value;
                 lcon[lindex[index]].Location = item.Key;
             }
             catch { }
             index++;
         }
     }
     catch { }
 }
Example #19
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 #20
0
        public List <string> search(string name)
        {
            List <string> res     = new List <string>();
            string        address = "";
            bool          bb      = (_search || ((_reclusive || r) && (_file || f || _directory || d || _delete || _create || c || _new)));

            if (bb)
            {
                address = HERE.current;
            }
            else
            {
                address = getpath(name);
            }
            if (_file || f)
            {
                if (isfile(address))
                {
                    res.Add(address);
                }
                else
                {
                    res = MiMFa_Path.GetAllFiles(address, (_reclusive || r));
                }
            }
            else if (_directory || d)
            {
                res = MiMFa_Path.GetAllDirectories(address, (_reclusive || r));
            }
            else
            {
                res = MiMFa_CollectionService.Concat(MiMFa_Path.GetAllDirectories(address, (_reclusive || r)), MiMFa_Path.GetAllFiles(address, (_reclusive || r)));
            }
            if (bb && !name.Contains("\\"))
            {
                res = (from vv in res where vv.Split('\\').Last().Contains(name) select vv).ToList();
            }
            return(res);
        }
Example #21
0
 public void Receive()
 {
     try
     {
         byte[] buffer = new byte[BufferSize];
         // Receives data from a bound Socket.
         //int bytesRec = SenderSock.Receive(buffer);
         // Continues to read the data till data isn't available
         while (SenderSock.Available > 0)
         {
             int bytesRec = SenderSock.Receive(buffer);
             if (bytesRec > 0)
             {
                 ReceiveCallBackData(MiMFa_CollectionService.GetPart(buffer, 0, bytesRec - 1), InterlocutorIPEndPoint, bytesRec);
             }
         }
     }
     catch (Exception ex)
     {
         ErrorReceiveCallBackData(SenderSock, InterlocutorIPEndPoint, 0, ex);
     }
 }
Example #22
0
        public override object EXECUTE(params object[] po)
        {
            if (po == null)
            {
                throw new System.Exception("This command must be have inputs!");
            }
            if (_executecode)
            {
                string   code          = po[0].ToString();
                string   namespacename = "MRL";
                string   classname     = "Program";
                string   functionname  = "Main";
                bool     isstatic      = true;
                object[] args          = null;
                try
                {
                    namespacename = po[1].ToString();;
                    classname     = po[2].ToString();;
                    functionname  = po[3].ToString();
                    isstatic      = Convert.ToBoolean(po[4]);
                    args          = MiMFa_CollectionService.GetPart(po, 5);
                }
                catch { }
                executecode(code, namespacename, classname, functionname, isstatic, args);
            }
            else
            {
                string code    = po[0].ToString();
                string address = "out.exe";
                if (po.Length > 1)
                {
                    address = po[1].ToString().Trim();
                }
                return(provide(code, address));
            }

            return(Null);
        }
Example #23
0
        public object load(params object[] po)
        {
            object[] obj = null;
            MiMFa_IOService.OpenDeserializeFile <object[]>(PATH.getpath(po[0] + extention), ref obj);
            bool b = !_workspacelist && !_functionslist && !_handlerslist && !h && !f && !w;

            if (_handlerslist || h)
            {
                MiMFa_CommandLanguage.HandlersList.AddRange((List <object>)obj[0]);
                MiMFa_CommandLanguage.HandlersList = MiMFa_CollectionService.Distinct(MiMFa_CommandLanguage.HandlersList);
            }
            if (b || _workspacelist || w)
            {
                MiMFa_CommandLanguage.WorkSpaceList.AddRange((MiMFa_List <Variable>)obj[1]);
                MiMFa_CommandLanguage.WorkSpaceList = MiMFa_CollectionService.Distinct(MiMFa_CommandLanguage.WorkSpaceList);
            }
            if (b || _functionslist || f)
            {
                MiMFa_CommandLanguage.FunctionsList.AddRange((MiMFa_List <Function>)obj[2]);
                MiMFa_CommandLanguage.FunctionsList = MiMFa_CollectionService.Distinct(MiMFa_CommandLanguage.FunctionsList);
            }
            return(Null);
        }
Example #24
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);
 }
Example #25
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()));
        }
Example #26
0
        private static string LikeLapSignE(string expr, params string[] signs)
        {
            while (expr.Contains("+-") || expr.Contains("-+") || expr.Contains("++") || expr.Contains("--"))
            {
                expr = expr.Replace("()", "0").Replace(")(", ")*(").Replace("+-", "-").Replace("-+", "-").Replace("++", "+").Replace("--", "+");
            }
            string[] ca1 = { "√", "^", "%", "×", "*", "÷", "\\", "+", "-" };
            Func <string, string> func = (sign) =>
            {
                string[] sa = expr.Split(new string[] { sign }, StringSplitOptions.None);
                if (sa.Length <= 1)
                {
                    return(expr);
                }
                string[] arr  = sa[0].Split(ca1, StringSplitOptions.None);
                string   op1  = arr[arr.Length - 1];
                string   op2  = sa[1];
                double   dop2 = 0;
                if (op2.StartsWith("+"))
                {
                    arr  = sa[1].Split(ca1, StringSplitOptions.None);
                    op2  = "+" + arr[1];
                    dop2 = Convert.ToDouble(arr[1]);
                }
                else if (op2.StartsWith("-"))
                {
                    arr  = sa[1].Split(ca1, StringSplitOptions.None);
                    op2  = "-" + arr[1];
                    dop2 = -1 * Convert.ToDouble(arr[1]);
                }
                else
                {
                    arr  = sa[1].Split(ca1, StringSplitOptions.None);
                    op2  = arr[0];
                    dop2 = Convert.ToDouble(arr[0]);
                }
                string result = EvaluateString(op1, sign, dop2).ToString();
                expr = expr.Replace(op1 + sign + op2, MiMFa_Convert.ForceToDouble(result).ToString());
                return(expr);
            };

            if (expr.Split(signs, StringSplitOptions.None).Length > 1)
            {
                do
                {
                    Dictionary <int, string> collection = new Dictionary <int, string>();
                    for (int i = 0; i < expr.Length; i++)
                    {
                        foreach (var item in signs)
                        {
                            if (expr[i].ToString() == item)
                            {
                                collection.Add(i, item); break;
                            }
                        }
                    }
                    collection = MiMFa_CollectionService.Sort(collection, (d1, d2) => d1.Key < d2.Key);
                    foreach (var item in collection)
                    {
                        expr = func(item.Value);
                    }
                }while (expr.Split(signs, StringSplitOptions.RemoveEmptyEntries).Length > 1);
            }
            return(expr);
        }
Example #27
0
 public override string ToString()
 {
     return(MiMFa_CollectionService.GetAllItems(Items, SplitSign, 0));
 }
Example #28
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 #29
0
        public MiMFa_Table GetTable(FetchPatern patern, List <MiMFa_XMLElement> xmls)
        {
            MiMFa_Table mdt = new MiMFa_Table();

            if (patern.HTMLElementsPatern == null)
            {
                return(mdt);
            }
            List <HTMLElementPatern> continuehep = new List <HTMLElementPatern>();

            MiMFa_CollectionService.CopyTo(ref continuehep, patern.HTMLElementsPatern);
            List <MiMFa_XMLElement> me = new List <MiMFa_XMLElement>();

            foreach (var item in patern.HTMLElementsPatern)
            {
                me.Add(item.SampleHTMLElement);
            }
            MiMFa_XMLElement e = MiMFa_XMLElement.GetElementsCommonParent(me);

            while (continuehep.Count > 0)
            {
                if (e != null)
                {
                    e = MiMFa_XMLElement.Find(xmls, e);
                }
                List <MiMFa_XMLElement> scope = e == null ? xmls : new List <MiMFa_XMLElement>()
                {
                    e
                };
                bool             all  = false;
                MiMFa_XMLElement elem = null;
                int len = continuehep.Count;
                for (int i = 0; i < len; i++)
                {
                    MiMFa_XMLElement ele = null;
                    mdt = GetTable(mdt, continuehep[i], scope, out ele);
                    if (continuehep[i].All != MiMFa_Boolean.True)
                    {
                        continuehep.RemoveAt(i);
                        i--;
                        len--;
                    }
                    else if (ele != null)
                    {
                        elem = ele;
                        all  = true;
                    }
                    if (ele != null)
                    {
                        if (continuehep.Count - 1 > i + 1 && continuehep[i].SampleHTMLElement == continuehep[i + 1].SampleHTMLElement.Parent)
                        {
                            ele.StartTag = "";
                        }
                        else
                        {
                            xmls = MiMFa_XMLElement.GetLastSplitIn(xmls, ele);
                        }
                    }
                }
                if (e == null)
                {
                    break;
                }
                if (elem == null)
                {
                    xmls = MiMFa_XMLElement.GetLastSplitIn(xmls, e);
                }
                else if (all)
                {
                    xmls = MiMFa_XMLElement.GetLastSplitIn(xmls, elem);
                }
                else
                {
                    break;
                }
            }
            //
            if (fetch_url.TransposeResult)
            {
                mdt = mdt.Transpose(true);
            }
            NumberOfLastTableRows = mdt.MainTable.Rows.Count - 1;
            NumberOfAllTableRows += NumberOfLastTableRows;
            if (string.IsNullOrWhiteSpace(fetch_url.TableAddress))
            {
                fetch_url.TableAddress = TempDirectory + DateTime.Now.Ticks + MiMFa_Table.Extention;
            }
            if (NumberOfLastTableRows > 0)
            {
                try
                {
                    if (!string.IsNullOrWhiteSpace(fetch_url.Source))
                    {
                        DataColumn dcs = mdt.AddColumnSafe("auto_Source");
                        for (int i = 1; i < mdt.Rows.Count; i++)
                        {
                            mdt.Rows[i][dcs] = fetch_url.Source;
                        }
                    }
                }
                catch { }
            }
            try
            {
                MiMFa_Table nmt = null;
                MiMFa_IOService.OpenDeserializeFile(fetch_url.TableAddress, ref nmt);
                if (nmt != null)
                {
                    nmt = MiMFa_Table.ConcatTable(nmt, mdt);
                }
            }
            catch { }
            MiMFa_IOService.SaveSerializeFile(fetch_url.TableAddress, mdt);
            return(mdt);
        }
Example #30
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(" ");
        }