Пример #1
0
        /// <summary>
        /// Initializes a new instance of <see cref="SixParamsFunctionNode"/> class.
        /// </summary>
        /// <param name="nodeType">The type of the current node.</param>
        /// <param name="parameter1">The function first parameter value.</param>
        /// <param name="parameter2">The function second parameter value.</param>
        /// <param name="parameter3">The function third parameter value.</param>
        /// <param name="parameter4">The function fourth parameter value.</param>
        /// <param name="parameter5">The function fifth parameter value.</param>
        /// <param name="parameter6">The function sixth parameter value.</param>
        protected SixParamsFunctionNode(ExpressionNodeType nodeType, ExpressionNode parameter1, ExpressionNode parameter2, ExpressionNode parameter3, ExpressionNode parameter4, ExpressionNode parameter5, ExpressionNode parameter6)
            : this(nodeType)
        {
            if (parameter1 == null)
                throw new ArgumentException("Parameter 'parameter1' should contain a value.", "parameter1");
            
            if (parameter2 == null)
                throw new ArgumentException("Parameter 'parameter2' should contain a value.", "parameter2");

            if (parameter3 == null)
                throw new ArgumentException("Parameter 'parameter3' should contain a value.", "parameter3");

            if (parameter4 == null)
                throw new ArgumentException("Parameter 'parameter4' should contain a value.", "parameter4");

            if (parameter5 == null)
                throw new ArgumentException("Parameter 'parameter5' should contain a value.", "parameter5");

            if (parameter6 == null)
                throw new ArgumentException("Parameter 'parameter6' should contain a value.", "parameter6");

            Parameter1 = parameter1;
            Parameter2 = parameter2;
            Parameter3 = parameter3;
            Parameter4 = parameter4;
            Parameter5 = parameter5;
            Parameter6 = parameter6;
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of <see cref="SingleParamFunctionNode"/> class.
        /// </summary>
        /// <param name="nodeType">The type of the current node.</param>
        /// <param name="parameter">The function parameter value.</param>
        /// <exception cref="System.ArgumentException">Parameter 'parameter' should contain a value.;parameter</exception>
        public SingleParamFunctionNode(ExpressionNodeType nodeType, ExpressionNode parameter)
            : this(nodeType)
        {
            if (parameter == null)
                throw new ArgumentException("Parameter 'parameter' should contain a value.", "parameter");

            Parameter = parameter;
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of <see cref="ResultNode"/> class.
        /// </summary>
        /// <param name="fieldName">Name of the field.</param>
        /// <param name="expression">The result expression.</param>
        public ResultNode(string fieldName, ExpressionNode expression) : base(ExpressionNodeType.Result)
        {
            if (String.IsNullOrEmpty(fieldName))
                throw new ArgumentException("Parameter 'fieldName' should contain a value.", "fieldName");

            if (expression == null)
                throw new ArgumentException("Parameter 'expression' should contain a value.", "expression");

            FieldName = fieldName;
            Expression = expression;
        }
Пример #4
0
        /// <summary>
        /// Initializes a new instance of <see cref="SingleParamFunctionNode"/> class.
        /// </summary>
        /// <param name="nodeType">The type of the current node.</param>
        /// <param name="parameter1">The function first parameter value.</param>
        /// <param name="parameter2">The function second parameter value.</param>
        protected TwoParamsFunctionNode(ExpressionNodeType nodeType, ExpressionNode parameter1, ExpressionNode parameter2)
            : this(nodeType)
        {
            if (parameter1 == null)
                throw new ArgumentException("Parameter 'parameter1' should contain a value.", "parameter1");
            
            if (parameter2 == null)
                throw new ArgumentException("Parameter 'parameter2' should contain a value.", "parameter2");

            Parameter1 = parameter1;
            Parameter2 = parameter2;
        }
Пример #5
0
        /// <summary>
        /// Initializes a new instance of <see cref="IfStatementNode"/> class.
        /// </summary>
        /// <param name="conditionNode">Condition to check.</param>
        /// <param name="trueNode">true node result.</param>
        /// <param name="falseNode">false node result.</param>
        public IfStatementNode(ExpressionNode conditionNode, ExpressionNode trueNode, ExpressionNode falseNode)
            :base(ExpressionNodeType.If)
        {
            if (conditionNode == null)
                throw new ArgumentException("Parameter 'conditionNode' should contain a value.", "conditionNode");
            if (trueNode == null)
                throw new ArgumentException("Parameter 'trueNode' should contain a value.", "trueNode");
            if (falseNode == null)
                throw new ArgumentException("Parameter 'falseNode' should contain a value.", "falseNode");

            ConditionNode = conditionNode;

            TrueNode = trueNode;

            FalseNode = falseNode;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="SetChecklistDataFunctionNode"/> class.
 /// </summary>
 /// <param name="parameter">
 /// The parameter.
 /// </param>
 /// <param name="id">
 /// The node id.
 /// </param>
 public SetChecklistDataFunctionNode(ExpressionNode parameter, Guid id)
     : base(ExpressionNodeType.SetChecklistData, parameter)
 {
     Id = id;
 }
        private ExpressionFunction ConvertNode(ExpressionNode node)
        {
            var result = new ExpressionFunction();

            var sourceFieldNode = node as SourceFieldNode;
            if (sourceFieldNode != null)
            {
                result.FunctionType = "source";
                result.Definition = new ExpressionSourceFunctionDefinition
                {
                    Key = GetSourceFieldName(sourceFieldNode),
                    SetName = sourceFieldNode.SetName
                };
                return result;
            }

            var constantNode = node as ConstantNode;
            if (constantNode != null)
            {
                result.FunctionType = "constant";
                result.Definition = new ExpressionConstantFunctionDefinition { Value = constantNode.Value };
                return result;
            }

            var isNullNode = node as IsNullFunctionNode;
            if (isNullNode != null)
            {
                result.FunctionType = isNullNode.NodeType.ToString().ToLowerInvariant();
                result.Definition = new ExpressionOneInputFunctionDefinition
                {
                    In1 = ConvertNode(isNullNode.Parameter)
                };
                return result;
            }

            var notNode = node as NotFunctionNode;
            if (notNode != null)
            {
                result.FunctionType = notNode.NodeType.ToString().ToLowerInvariant();
                result.Definition = new ExpressionOneInputFunctionDefinition
                {
                    In1 = ConvertNode(notNode.Parameter)
                };
                return result;
            }

            var toUpperNode = node as ToUpperFunctionNode;
            if (toUpperNode != null)
            {
                result.FunctionType = toUpperNode.NodeType.ToString().ToLowerInvariant();
                result.Definition = new ExpressionOneInputFunctionDefinition
                {
                    In1 = ConvertNode(toUpperNode.Parameter)
                };
                return result;
            }

            var toLowerNode = node as ToLowerFunctionNode;
            if (toLowerNode != null)
            {
                result.FunctionType = toLowerNode.NodeType.ToString().ToLowerInvariant();
                result.Definition = new ExpressionOneInputFunctionDefinition
                {
                    In1 = ConvertNode(toLowerNode.Parameter)
                };
                return result;
            }

            var trimNode = node as TrimFunctionNode;
            if (trimNode != null)
            {
                result.FunctionType = trimNode.NodeType.ToString().ToLowerInvariant();
                result.Definition = new ExpressionOneInputFunctionDefinition
                {
                    In1 = ConvertNode(trimNode.Parameter)
                };
                return result;
            }

            var twoParamsNode = node as TwoParamsFunctionNode;
            if (twoParamsNode != null)
            {
                result.FunctionType = twoParamsNode.NodeType.ToString().ToLowerInvariant();
                result.Definition = new ExpressionTwoInputFunctionDefinition
                {
                    In1 = ConvertNode(twoParamsNode.Parameter1),
                    In2 = ConvertNode(twoParamsNode.Parameter2)
                };
                return result;
            }

            var threeParamsNode = node as ThreeParamsFunctionNode;
            if (threeParamsNode != null)
            {
                result.FunctionType = threeParamsNode.NodeType.ToString().ToLowerInvariant();
                result.Definition = new ExpressionThreeInputFunctionDefinition
                {
                    In1 = ConvertNode(threeParamsNode.Parameter1),
                    In2 = ConvertNode(threeParamsNode.Parameter2),
                    In3 = ConvertNode(threeParamsNode.Parameter3)
                };
                return result;
            }

            var ifFunctionNode = node as IfStatementNode;
            if (ifFunctionNode != null)
            {
                result.FunctionType = ifFunctionNode.NodeType.ToString().ToLowerInvariant();
                result.Definition = new ExpressionThreeInputFunctionDefinition
                {
                    In1 = ConvertNode(ifFunctionNode.ConditionNode),
                    In2 = ConvertNode(ifFunctionNode.TrueNode),
                    In3 = ConvertNode(ifFunctionNode.FalseNode)
                };
                return result;
            }

            var dateDayNode = node as DateDayFunctionNode;
            if (dateDayNode != null)
            {
                result.FunctionType = dateDayNode.NodeType.ToString().ToLowerInvariant();
                result.Definition = new ExpressionOneInputFunctionDefinition
                {
                    In1 = ConvertNode(dateDayNode.Parameter)
                };
                return result;
            }

            var dateNode = node as DateFunctionNode;
            if (dateNode != null)
            {
                result.FunctionType = dateNode.NodeType.ToString().ToLowerInvariant();
                result.Definition = new ExpressionOneInputFunctionDefinition
                {
                    In1 = ConvertNode(dateNode.Parameter)
                };
                return result;
            }

            var dateMonthNode = node as DateMonthFunctionNode;
            if (dateMonthNode != null)
            {
                result.FunctionType = dateMonthNode.NodeType.ToString().ToLowerInvariant();
                result.Definition = new ExpressionOneInputFunctionDefinition
                {
                    In1 = ConvertNode(dateMonthNode.Parameter)
                };
                return result;
            }

            var dateMonthNameNode = node as DateMonthNameFunctionNode;
            if (dateMonthNameNode != null)
            {
                result.FunctionType = dateMonthNameNode.NodeType.ToString().ToLowerInvariant();
                result.Definition = new ExpressionOneInputFunctionDefinition
                {
                    In1 = ConvertNode(dateMonthNameNode.Parameter)
                };
                return result;
            }

            var dateQuarterNode = node as DateQuarterFunctionNode;
            if (dateQuarterNode != null)
            {
                result.FunctionType = dateQuarterNode.NodeType.ToString().ToLowerInvariant();
                result.Definition = new ExpressionOneInputFunctionDefinition
                {
                    In1 = ConvertNode(dateQuarterNode.Parameter)
                };
                return result;
            }

            var dateWeekNode = node as DateWeekFunctionNode;
            if (dateWeekNode != null)
            {
                result.FunctionType = dateWeekNode.NodeType.ToString().ToLowerInvariant();
                result.Definition = new ExpressionOneInputFunctionDefinition
                {
                    In1 = ConvertNode(dateWeekNode.Parameter)
                };
                return result;
            }

            var dateYearNode = node as DateYearFunctionNode;
            if (dateYearNode != null)
            {
                result.FunctionType = dateYearNode.NodeType.ToString().ToLowerInvariant();
                result.Definition = new ExpressionOneInputFunctionDefinition
                {
                    In1 = ConvertNode(dateYearNode.Parameter)
                };
                return result;
            }

            var countNode = node as CountFunctionNode;
            if (countNode != null)
            {
                result.FunctionType = countNode.NodeType.ToString().ToLowerInvariant();
                result.Definition = new ExpressionOneInputFunctionDefinition
                {
                    In1 = ConvertNode(countNode.Parameter)
                };
                return result;
            }

            var lengthNode = node as LengthFunctionNode;
            if (lengthNode != null)
            {
                result.FunctionType = lengthNode.NodeType.ToString().ToLowerInvariant();
                result.Definition = new ExpressionOneInputFunctionDefinition
                {
                    In1 = ConvertNode(lengthNode.Parameter)
                };
                return result;
            }

            return result;
        }