public object Evaluate(Token contextToken, List<ExpressionArgument> args, ExecutionState state) { if(args.Count != 2) throw new InstructionExecutionException("The FormField expression must take two arguments. The first is the name of the field, " + "the second is the default value to use if no value has been preset for that field name.", contextToken); string fieldname = args[0].Expression.Evaluate(state,args[0].Token) as string; if (FormValues.HasValue(fieldname)) return FormValues.Get(fieldname); FormValues.FormFieldInfo fld = new FormValues.FormFieldInfo(); fld.IsError = false; fld.Message = ""; fld.Name = fieldname; fld.Value = args[1].Expression.Evaluate(state, args[1].Token); return fld; }
public object Evaluate(Token contextToken, List <ExpressionArgument> args, ExecutionState state) { if (args.Count != 2) { throw new InstructionExecutionException("The FormField expression must take two arguments. The first is the name of the field, " + "the second is the default value to use if no value has been preset for that field name.", contextToken); } string fieldname = args[0].Expression.Evaluate(state, args[0].Token) as string; if (FormValues.HasValue(fieldname)) { return(FormValues.Get(fieldname)); } FormValues.FormFieldInfo fld = new FormValues.FormFieldInfo(); fld.IsError = false; fld.Message = ""; fld.Name = fieldname; fld.Value = args[1].Expression.Evaluate(state, args[1].Token); return(fld); }