Beispiel #1
0
/*
 *              //今のコマンドから、エンティティ処理したコマンドを作成
 *              public static AdvCommand CreateEntityCommand( AdvCommand original, AdvEngine engine, AdvScenarioPageData pageData)
 *              {
 *                      StringGridRow row;
 *                      if (!TryParseRowDataEntity(original.EntityData, engine.Param.GetParameter, out row))
 *                      {
 *                              Debug.LogError("Enity Parse Error");
 *                              return original;
 *                      }
 *
 *                      AdvCommand entityCommand = AdvCommandParser.CreateCommand( original.Id, row, engine.DataManager.SettingDataManager);
 *                      if (entityCommand is AdvCommandText)
 *                      {
 *                              AdvCommandText textCommand = entityCommand as AdvCommandText;
 *                              textCommand.InitOnCreateEntity(original as AdvCommandText);
 *                      }
 *                      return entityCommand;
 *              }
 *
 *              //今のコマンドから、エンティティ処理したデータを作成
 *              static public bool TryParseRowDataEntity(StringGridRow original, System.Func<string, object> GetParameter, out StringGridRow row)
 *              {
 *                      Profiler.BeginSample("TryParseRowDataEntity");
 *                      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();
 *                      }
 *                      Profiler.EndSample();
 *                      return ret;
 *              }
 */
        static bool CheckEntitySeparator(char c)
        {
            switch (c)
            {
            case '[':
            case ']':
            case '.':
                return(true);

            default:
                return(ExpressionToken.CheckSeparator(c));
            }
        }
        private static bool CheckEntitySeparator(char c)
        {
            switch (c)
            {
            case '[':
            case ']':
                break;

            default:
                if (c != '.')
                {
                    return(ExpressionToken.CheckSeparator(c));
                }
                break;
            }
            return(true);
        }