Пример #1
0
        //今のコマンドから、エンティティ処理したデータを作成
        static bool TryParseRowDataEntity(StringGridRow original, System.Func <string, object> GetParameter, out StringGridRow row)
        {
            bool ret = false;

            row = original.Clone(() => original.Grid);

            List <int> ignoreIndex = AdvParser.CreateMacroOrEntityIgnoreIndexArray(original.Grid);

            for (int i = 0; i < row.Strings.Length; ++i)
            {
                string str = row.Strings[i];
                if (ignoreIndex.Contains(i))
                {
                    continue;
                }
                if (str.Length <= 1)
                {
                    continue;
                }
                if (!str.Contains("&"))
                {
                    continue;
                }


                StringBuilder builder = new StringBuilder();
                int           index   = 0;
                while (index < str.Length)
                {
                    if (str[index] == '&')
                    {
                        bool isEntity = false;
                        int  index2   = index + 1;
                        while (index2 < str.Length)
                        {
                            if (index2 == str.Length - 1 || CheckEntitySeparator(str[index2 + 1]))
                            {
                                string key   = str.Substring(index + 1, index2 - index);
                                object param = GetParameter(key);
                                if (param != null)
                                {
                                    builder.Append(param.ToString());
                                    index    = index2 + 1;
                                    isEntity = true;
                                }
                                break;
                            }
                            else
                            {
                                ++index2;
                            }
                        }
                        if (isEntity)
                        {
                            ret = true;
                            continue;
                        }
                    }

                    builder.Append(str[index]);
                    ++index;
                }
                row.Strings[i] = builder.ToString();
            }
            return(ret);
        }