Пример #1
0
        //マクロ処理した行データを取得
        public List <StringGridRow> MakeMacroRows(StringGridRow args)
        {
            List <StringGridRow> list = new List <StringGridRow>();

            if (DataList.Count <= 0)
            {
                return(list);
            }

            StringGrid macroGrid = DataList[0].Grid;
            string     gridName  = args.Grid.Name + ":" + (args.RowIndex + 1).ToString() + "-> Macro : " + macroGrid.Name;
            StringGrid grid      = new StringGrid(gridName, args.Grid.SheetName, macroGrid.Type);

            grid.Macro          = new StringGrid.MacroInfo(args);
            grid.ColumnIndexTbl = macroGrid.ColumnIndexTbl;
            List <int> ignoreIndexArray = AdvParser.CreateMacroOrEntityIgnoreIndexArray(grid);

            for (int i = 0; i < DataList.Count; ++i)
            {
                StringGridRow macroData = DataList[i].Clone(() => (grid));
                macroData.Macro(args, Header, ignoreIndexArray);
                list.Add(macroData);
            }
            return(list);
        }
Пример #2
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);
        }