private ConstantNode CreateConstantFromParameter(ParameterNode parameterNode) { if (string.Equals(parameterNode.ParameterName, "project")) { ConstantNode node = new ConstantNode(context.ProjectId.ToString()); node.DataType = ValueDataType.Number; return node; } else if (string.Equals(parameterNode.ParameterName, "me")) { ConstantNode node = new ConstantNode("'" + context.Me + "'"); node.DataType = ValueDataType.String; return node; } else if (parameterNode.ParameterName.IndexOf("today", StringComparison.OrdinalIgnoreCase) > -1) { //TODO: Do date time calc ConstantNode node = new ConstantNode(DateTime.Now.ToString("s") + "Z"); node.DataType = ValueDataType.DateTime; return node; } else { throw new Exception("Unknown parameter name"); } }
private Node SetState(CursorState state, string word) { Node node = null; if (state != currentState) { if (state == CursorState.FieldName) { node = new FieldNode(word); } if (state == CursorState.Condition) { node = new ConditionNode(word); } if (state == CursorState.Parameter) { node = new ParameterNode(word); } if (state == CursorState.Constant) { node = new ConstantNode(word); } if (state == CursorState.ArrayOfValues) { node = new ArrayOfValues(word); } if (state == CursorState.OpenBracket) { node = new OpenBracketNode(); } if (state == CursorState.CloseBracket) { node = new CloseBracketNode(); } if (state == CursorState.Operator) { node = new OperatorNode(word); } if (node != null) nodes.Add(node); currentState = state; } return node; }