Exemplo n.º 1
0
        public void Act(CSVRow row, Dictionary <string, string> vars)
        {
            switch (type)
            {
            case ExpressionType.Print :
                Console.WriteLine(row);
                break;

            case ExpressionType.Set:
                if (fieldValue.Length > 0 &&
                    fieldValue[0] == '$' &&
                    vars.ContainsKey(fieldValue.Substring(1)))
                {
                    row.SetEntry(fieldName, vars[fieldValue.Substring(1)]);
                }
                else
                {
                    row.SetEntry(fieldName, fieldValue);
                }
                break;

            case ExpressionType.Let:
                if (!vars.ContainsKey(fieldName))
                {
                    vars.Add(fieldName, "");
                }
                if (row.Contains(fieldValue))
                {
                    vars[fieldName] = row.GetEntry(fieldValue);
                }
                else
                {
                    vars[fieldName] = fieldValue;
                }
                break;
            }
            if (next != null)
            {
                next.Act(row, vars);
            }
        }