예제 #1
0
    public void GetMatchList(Action <bool, string> func)
    {
        Backend.Match.GetMatchList(callback =>
        {
            if (callback.IsSuccess() == false)
            {
                Debug.Log("매칭 카드 불러오기 실패");
                Dispatcher.Current.BeginInvoke(() =>
                {
                    GetMatchList(func);
                }
                                               );
                return;
            }
            foreach (LitJson.JsonData row in callback.Rows())
            {
                MatchInfo info = new MatchInfo();
                info.indate    = row["inDate"]["S"].ToString();
                foreach (MatchType type in Enum.GetValues(typeof(MatchType)))
                {
                    info.matchType = type;
                }
                foreach (MatchModeType type in Enum.GetValues(typeof(MatchModeType)))
                {
                    info.matchModeType = type;
                }

                MatchInfos.Add(info);
            }
            Debug.Log("매치 카드 생성 완료");
            func(true, string.Empty);
        });
    }
예제 #2
0
        static private MatchInfos GetMinMatchData(string source, string startMatch, string endMatch,
                                                  char exceptSChr, char exceptEChr)
        {
            MatchInfos result = new MatchInfos();

            string rStart = "<";
            string rEnd   = ">";

            if (rStart == startMatch)
            {
                rStart = "(";
            }
            if (rEnd == endMatch)
            {
                rEnd = ")";
            }

            MatchCollection mc = null;

            if ((exceptSChr != '\0') && (exceptEChr != '\0'))
            {
                mc = Regex.Matches(source, "[\\" + exceptSChr + "](.*?)[\\" + exceptEChr + "]");

                for (int i = 0; i <= mc.Count - 1; i++)
                {
                    source = source.Replace(mc[i].Value, rStart + "@" + i + "/" + rEnd);
                }
            }

            string tmp = source;

            int startMatchLen = startMatch.Length;
            int endMatchLen   = endMatch.Length;

            int indexStart = tmp.IndexOf(startMatch);

            if (indexStart < 0)
            {
                return(result);               //没有匹配项,则直接退出
            }
            int indexEnd  = tmp.IndexOf(endMatch);
            int indexNext = tmp.IndexOf(startMatch, indexStart + startMatchLen);

            if (indexNext <= 0)
            {
                indexNext = tmp.Length;
            }

            while (indexStart >= 0)
            {
                if (indexStart >= 0 && indexEnd > 0 && indexEnd > indexStart && indexEnd < indexNext)//满足[xxx]这种形式,过滤[xxx[bbb]这种形式
                {
                    string context = tmp.Substring(indexStart + startMatchLen, indexEnd - indexStart - startMatchLen);

                    if (mc != null && context.IndexOf("<@") >= 0)
                    {
                        for (int i = 0; i <= mc.Count - 1; i++)
                        {
                            context = context.Replace(rStart + "@" + i + "/" + rEnd, mc[i].Value);
                        }
                    }

                    result.Add(new MatchInfo(context, indexStart));

                    tmp = tmp.Substring(indexEnd + endMatchLen);
                }
                else
                {
                    tmp = tmp.Substring(indexStart + startMatchLen);
                }

                if (tmp.Length <= 0)
                {
                    break;
                }

                indexStart = tmp.IndexOf(startMatch);
                indexEnd   = tmp.IndexOf(endMatch);

                indexNext = tmp.IndexOf(startMatch, (indexStart < 0) ? 0 : indexStart + startMatchLen);

                if (indexNext <= 0)
                {
                    indexNext = tmp.Length;
                }
            }

            return(result);
        }