Exemple #1
0
 public ExpressionGene(GeneType type, Operator?op = null, double number = 0, int variable = 0)
 {
     Type     = type;
     Operator = op;
     Number   = number;
     Variable = variable;
 }
Exemple #2
0
 public bool Match(BinaryExpression binExp)
 {
     addr     = null;
     cLeft    = binExp.Left as Constant;
     cRight   = binExp.Right as Constant;
     dtResult = binExp.DataType;
     op       = binExp.Operator;
     if (cLeft != null && cRight != null)
     {
         if (op is ConditionalOperator)
         {
             return(true);
         }
         if (!cLeft.IsReal && !cRight.IsReal)
         {
             if (cLeft.DataType.IsPointer)
             {
                 dtResult = cLeft.DataType;
             }
             else if (cRight.DataType.IsPointer)
             {
                 dtResult = cRight.DataType;
             }
             return(true);
         }
     }
     if (binExp.Left is Address a && cRight != null &&
         (op == Operator.IAdd || op == Operator.ISub))
     {
         addr     = a;
         dtResult = a.DataType;
         return(true);
     }
     return(false);
 }
Exemple #3
0
 public XlsxDataValidation(
     bool allowBlank               = false,
     string error                  = null,
     string errorTitle             = null,
     ErrorStyle?errorStyle         = null,
     Operator?operatorType         = null,
     string prompt                 = null,
     string promptTitle            = null,
     bool showDropDown             = false,
     bool showErrorMessage         = false,
     bool showInputMessage         = false,
     ValidationType?validationType = null,
     string formula1               = null,
     string formula2               = null)
 {
     AllowBlank          = allowBlank;
     Error               = error;
     ErrorTitle          = errorTitle;
     ErrorStyleValue     = errorStyle;
     OperatorValue       = operatorType;
     Prompt              = prompt;
     PromptTitle         = promptTitle;
     ShowDropDown        = showDropDown;
     ShowErrorMessage    = showErrorMessage;
     ShowInputMessage    = showInputMessage;
     ValidationTypeValue = validationType;
     Formula1            = formula1;
     Formula2            = formula2;
 }
Exemple #4
0
        // (x << c) + x ==> x * ((1<<c) + 1)
        // (x << c) - x ==> x * ((1<<c) - 1)
        public bool Match(BinaryExpression b)
        {
            this.op = b.Operator;
            if (op == Operator.IAdd)
            {
                factor = 1;
            }
            else if (op == Operator.ISub)
            {
                factor = -1;
            }
            else
            {
                return(false);
            }
            var bin = b.Left as BinaryExpression;

            id = b.Right as Identifier;
            if (bin == null || id == null)
            {
                bin = b.Right as BinaryExpression;
                id  = b.Left as Identifier;
            }
            if (bin == null || bin.Left != id || bin.Operator != Operator.Shl)
            {
                return(false);
            }
            this.c  = bin.Right as Constant;
            this.dt = b.DataType;
            return(c != null);
        }
Exemple #5
0
 private void ApplyResult(int result)
 {
     _tempValue   = result;
     DisplayValue = _tempValue.ToString();
     _operator    = null;
     _isValue     = false;
 }
        public void QueryTransactions_ShouldAllowFilteringWithOperator(string value, Operator?op)
        {
            var filter = new Filter {
                Value = value, Field = Field.Email, Operator = op
            };
            var request = TestHelper.GetQueryTransactionModel(new List <Filter> {
                filter
            });
            var response = CheckoutClient.ReportingService.QueryTransaction(request);

            response.Should().NotBeNull();
            response.HttpStatusCode.Should().Be(HttpStatusCode.OK);

            if (op == Operator.Begins)
            {
                response.Model.Data.Should().OnlyContain(t => t.Customer.Email.StartsWith(value, _ignoreCase));
            }
            else if (op == Operator.Contains)
            {
                response.Model.Data.Should().OnlyContain(t => t.Customer.Email.Contains(value, _ignoreCase));
            }
            else if (op == Operator.Ends)
            {
                response.Model.Data.Should().OnlyContain(t => t.Customer.Email.EndsWith(value, _ignoreCase));
            }
            else
            {
                response.Model.Data.Should().OnlyContain(t => t.Customer.Email.Equals(value, _ignoreCase));
            }
        }
Exemple #7
0
        public bool Match(BinaryExpression b)
        {
            if (b.Operator != Operator.Shl)
            {
                return(false);
            }
            cShift = b.Right as Constant;
            if (cShift == null)
            {
                return(false);
            }

            if (!(b.Left is BinaryExpression bLeft))
            {
                return(false);
            }

            if (bLeft.Operator != Operator.SMul && bLeft.Operator != Operator.UMul && bLeft.Operator != Operator.IMul)
            {
                return(false);
            }
            op   = bLeft.Operator;
            cMul = bLeft.Right as Constant;
            if (cMul == null)
            {
                return(false);
            }

            e = bLeft.Left;
            return(true);
        }
        public void OnOperatorInput(Operator newOperator)
        {
            if (newOperator.SingleNumberOperator())
            {
                if (Num2 != null)
                {
                    Num2 = Calculate(Num2.Value, newOperator);
                }
                else
                {
                    Num1      = Calculate(Num1.Value, newOperator);
                    operator_ = null;
                }
            }
            else
            {
                if (operator_ == null)
                {
                    operator_ = newOperator;
                }
                else
                {
                    Num1      = Calculate(Num1.Value, Num2.Value, operator_.Value);
                    Num2      = null;
                    operator_ = newOperator;
                }
            }

            UpdateCalculation();
        }
        /// <summary>
        /// 构造矩阵运算的新异常
        /// </summary>
        /// <param name="o">异常运算符 (1 : '+', 2 : '-', 3 : '*', 5 : '乘方')</param>
        public MatrixTypeCalculateError(int o) : base()
        {
            ReasonMessage = "进行运算的矩阵类型发生错误";
            try
            {
                op = (Operator)o;
            }
            catch (NotImplementedException e)
            {
                WriteLine(e.Message);
            }
            switch (o)
            {
            case 1:
                DeepReason = "加法运算时矩阵的类型不相同";
                break;

            case 2:
                DeepReason = "减法运算时矩阵的类型不相同";
                break;

            case 3:
                DeepReason = "乘法运算时矩阵的行列关系不正确(应该为:左操作数的行数=右操作数的列数)";
                break;

            case 5:
                DeepReason = "乘方运算时参数不是方阵";
                break;

            default:
                DeepReason = "向异常类传递的参数应该o∈{1,2,3,4}(未知的异常)";
                break;
            }
        }
Exemple #10
0
 public bool Match(BinaryExpression b)
 {
     op = b.Operator;
     if (op != Operator.Shl && op != Operator.Shr && op != Operator.Sar)
     {
         return(false);
     }
     c1 = b.Right as Constant;
     if (c1 == null)
     {
         return(false);
     }
     if (!(b.Left is BinaryExpression b2))
     {
         return(false);
     }
     if (op != b2.Operator)
     {
         return(false);
     }
     c2 = b2.Right as Constant;
     if (c2 == null)
     {
         return(false);
     }
     e = b2.Left;
     return(true);
 }
Exemple #11
0
 //multiples values can be used in the filter, use operators and others values to build the filter query
 public string GetMoviesByFilter(Filter filter, string value, Operator?op = null, string value2 = null, Operator?op2 = null, string value3 = null,
                                 Operator?op3 = null, string value4 = null, Operator?op4 = null, string value5 = null, Operator?op5 = null, string value6 = null)
 {
     return(ExecuteRequest("/discover/movie", "&" + FilterToString(filter) + "=" + value +
                           (op is null ? "" : (op == Operator.AND) ? "," : "|") + value2 + (op2 is null ? "" : (op2 == Operator.AND) ? "," : "|") + value3 +
                           (op3 is null ? "" : (op3 == Operator.AND) ? "," : "|") + value4 + (op4 is null ? "" : (op4 == Operator.AND) ? "," : "|") + value5 +
                           (op5 is null ? "" : (op5 == Operator.AND) ? "," : "|") + value6));
 }
Exemple #12
0
 /// <summary>
 /// 添加参数
 /// </summary>
 /// <param name="name">参数名</param>
 /// <param name="value">参数值</param>
 /// <param name="operator">运算符</param>
 public void Add(string name, object value, Operator? @operator = null)
 {
     if (string.IsNullOrWhiteSpace(name))
     {
         return;
     }
     _params.Add(name, GetValue(value, @operator));
 }
        private void Clear()
        {
            _operandOne = null;
            _operandTwo = null;
            _operation  = null;

            DisplayValue = string.Empty;
        }
        public Expression ParseCondition()
        {
            var      stack = new Stack <IEvaluationStackNode>();
            Operator?mostRecentOperator = null;

            while (true)
            {
                var nextToken = _scanResult.Peek();
                if (nextToken.literal == "(")
                {
                    stack.Push(new ParenthesisOpenNode());
                    _scanResult.Next();
                    continue;
                }

                if (nextToken.tokenType == TokenType.Not)
                {
                    stack.Push(new OperatorNode(Operator.Not));
                    _scanResult.Next();
                    mostRecentOperator = Operator.Not;
                    continue;
                }

                stack.Push(ParseValue(mostRecentOperator));

                nextToken = _scanResult.Peek();
                var nextTokenType = nextToken.tokenType;

                if (nextToken.tokenType == TokenType.ParenthesisClose)
                {
                    CollapseStack(stack);
                    _scanResult.Next();
                    nextTokenType = _scanResult.Peek().tokenType;;
                }

                if (!IsBinaryOperator(nextTokenType))
                {
                    CollapseStack(stack);
                    return(((ValueNode)stack.Single()).Expressions.Single());
                }

                _scanResult.Next();

                var nextOperator = OperatorFor(nextTokenType);
                if (mostRecentOperator.HasValue)
                {
                    var nextPrecedence       = PrecendenceFor(nextOperator);
                    var mostRecentPrecedence = PrecendenceFor(mostRecentOperator.Value);
                    if (nextPrecedence < mostRecentPrecedence)
                    {
                        CollapseStack(stack);
                    }
                }

                stack.Push(new OperatorNode(nextOperator));
                mostRecentOperator = nextOperator;
            }
        }
        /// <summary>
        ///     Work out the result of an operation, and indicate what coercions if any are required to perform it
        /// </summary>
        /// <param name="op">the operation to perform</param>
        /// <param name="lhs">the tid of the lhs operand</param>
        /// <param name="rhs">the tid of the rhs operand</param>
        /// <returns>tuple (result tid, coercion type for lhs, coercion type for rhs)</returns>
        public static (TypeId, TypeId?, TypeId?) GetResultType(Operator?op, TypeId lhs, TypeId rhs)
        {
            if (!op.HasValue)
            {
                throw new ArgumentNullException(nameof(op));
            }

            return(GetResultType(op.Value, lhs, rhs));
        }
Exemple #16
0
 /// <summary>
 /// Operator is a relation-equals operator.
 /// </summary>
 /// <param name="op"></param>
 /// <returns></returns>
 private bool RelEq(Operator?op)
 {
     if (op is null)
     {
         return(false);
     }
     return(op == Operator.Le || op == Operator.Ge ||
            op == Operator.Ule || op == Operator.Uge);
 }
Exemple #17
0
 private void AddWhere(Operator?oper, string statement)
 {
     if (this.WhereBase.IsEmpty())
     {
         this.WhereBase += $"{statement} ";
     }
     else
     {
         this.WhereBase += $"{oper ?? Operator.AND} {statement} ";
     }
 }
        private void Clear()
        {
            _operandOne = null;
            _operandTwo = null;
            _operation  = null;

            DisplayValue = string.Empty;
            DisplayText  = string.Empty;
            _newDisplay  = string.Empty;
            _previousVal = string.Empty;
        }
Exemple #19
0
        public bool AddOperator(Operator operation)
        {
            if (!IsOperandUnset(operand1Txt) && (!this.operation.HasValue || this.operation.Value != operation))
            {
                this.operation = operation;

                return(true);
            }

            return(false);
        }
        private NodeList ExtractOperatorForward(int from, int to)
        {
            NodeList list            = new NodeList();
            Operator?currentOperator = null;

            for (int i = from; i < to; i++)
            {
                var node = this[i];
                if (node.NodeType == NodeType.OpenBracket)
                {
                    var closeBracket = FindMatchingCloseBracket(i);
                    var newList      = ExtractOperatorForward(i + 1, closeBracket);
                    i = closeBracket;
                    list.Add(new OpenBracketNode());
                    list.AddRange(newList);
                    list.Add(new CloseBracketNode());
                    continue;
                }
                if (node.NodeType == NodeType.Operator)
                {
                    var operatorNode = ((OperatorNode)node);
                    if (!currentOperator.HasValue)
                    {
                        currentOperator = operatorNode.Operator;
                        list.Insert(0, operatorNode);
                    }
                    else
                    {
                        if (currentOperator == operatorNode.Operator)
                        {
                            continue;
                        }
                        list.Add(operatorNode);
                    }
                }
                else
                {
                    list.Add(node);
                }
            }
            //Analyze list if last is only one operator and condition, push operator forward and mark previous as group.
            if (list.Count > 1)
            {
                if (list[list.Count - 1].NodeType == NodeType.Condition && list[list.Count - 2].NodeType == NodeType.Operator)
                {
                    var op = list[list.Count - 2];
                    list.RemoveAt(list.Count - 2);
                    list.Insert(0, op);
                    list.Insert(1, new OpenBracketNode());
                    list.Insert(list.Count - 1, new CloseBracketNode());
                }
            }
            return(list);
        }
 /// <summary>
 /// 标签群推(http://docs.developer.qq.com/xg/push_faq/server_api/rest.html#%E7%BE%A4%E6%8E%A8%E9%80%81)。
 /// <para>可以针对设置过标签的设备进行推送。如:性别、身份等。</para>
 /// <para>注意:单次发送tag不超过50个(<see cref="SendSingleTagsMaxCount"/>)个,若超过50个,推荐使用全量接口推送消息。</para>
 /// </summary>
 /// <param name="message"></param>
 /// <param name="tags"></param>
 /// <param name="operators">运算符,取值为 <see cref="Operator.AND"/> 或 <see cref="Operator.OR"/> ,默认值为 <see langword="null"/>(<see cref="Operator.OR"/>)。</param>
 /// <returns></returns>
 public Task <XingePushClientResult <SubPushIdsResult> > PushTags(
     [NotNull] MessageBase message, [NotNull] ICollection <string> tags, Operator?operators = null)
 {
     ValidationUtils.ArgumentNotNull(message, nameof(message));
     ValidationUtils.ArgumentNotNull(tags, nameof(tags));
     if (tags.Count > SendSingleTagsMaxCount)
     {
         throw new ArgumentOutOfRangeException(nameof(tags));
     }
     return(SendAsync <SubPushIdsResult>(RESTAPI_PUSHTAGS, message,
                                         new p(Constants.tags_list, tags),
                                         new p(Constants.tags_op, operators ?? Operator.OR)));
 }
Exemple #22
0
 /// <summary>
 /// 添加参数,如果参数已存在则替换
 /// </summary>
 /// <param name="name">参数名</param>
 /// <param name="value">参数值</param>
 /// <param name="operator">运算符</param>
 public void Add(string name, object value, Operator? @operator = null)
 {
     if (string.IsNullOrWhiteSpace(name))
     {
         return;
     }
     name = _dialect.GetParamName(name);
     if (_params.ContainsKey(name))
     {
         _params.Remove(name);
     }
     _params.Add(name, GetValue(value, @operator));
 }
Exemple #23
0
        public void WhereUniversal(Operator?oper, string where, object value)
        {
            if (value == null)
            {
                value = DBNull.Value;
            }

            var columnParameter = $"{this.OptionalName}custom{this.ColumnCount}";
            var statement       = string.Format(where, this.Param + columnParameter) + " ";

            this.AddWhere(oper, statement);
            this.Parameters.Add(columnParameter, ConvertToSafe.Convert(value));
            this.ColumnCount++;
        }
Exemple #24
0
        public override IQueryNode Process(IQueryNode queryTree)
        {
            Operator?op = GetQueryConfigHandler().Get(ConfigurationKeys.DEFAULT_OPERATOR);

            if (op == null)
            {
                throw new ArgumentException(
                          "StandardQueryConfigHandler.ConfigurationKeys.DEFAULT_OPERATOR should be set on the QueryConfigHandler");
            }

            this.usingAnd = Operator.AND == op;

            return(base.Process(queryTree));
        }
        private void ClearEntryCommandExecute()
        {
            if (_operandTwo.HasValue)
            {
                _operandTwo = null;
            }
            else
            {
                _operation  = null;
                _operandOne = null;
            }

            DisplayValue = string.Empty;
        }
        private void OperatorCommandExecute(string op)
        {
            Operator?operation;

            switch (op)
            {
            case "+":
                operation = Operator.Addition;
                break;

            case "-":
                operation = Operator.Subtraction;
                break;

            case "*":
                operation = Operator.Multiplication;
                break;

            case "/":
                operation = Operator.Division;
                break;

            default:
                throw new ArgumentException("Invalid Operator!");
            }

            if (_operandTwo.HasValue)
            {
                var calculation = Calculate();
                if (calculation != 0)
                {
                    _operandOne = calculation;
                    _operation  = operation;

                    DisplayValue = string.Empty;
                }
                else
                {
                    Clear();
                }
            }
            else if (_operandOne.HasValue)
            {
                _operation   = operation;
                DisplayValue = string.Empty;
            }
        }
Exemple #27
0
        public virtual IQueryNode Process(IQueryNode queryTree)
        {
            Operator?defaultOperator = GetQueryConfigHandler().Get(ConfigurationKeys.DEFAULT_OPERATOR);

            if (defaultOperator == null)
            {
                throw new ArgumentException(
                          "DEFAULT_OPERATOR should be set on the QueryConfigHandler");
            }

            this.usingAnd = Operator.AND == defaultOperator;

            if (queryTree is GroupQueryNode groupQueryNode)
            {
                queryTree = groupQueryNode.GetChild();
            }

            this.queryNodeList      = new List <IQueryNode>();
            this.latestNodeVerified = false;
            ReadTree(queryTree);

            List <IQueryNode> actualQueryNodeList = this.queryNodeList;

            for (int i = 0; i < actualQueryNodeList.Count; i++)
            {
                IQueryNode node = actualQueryNodeList[i];

                if (node is GroupQueryNode)
                {
                    actualQueryNodeList[i] = Process(node);
                }
            }

            this.usingAnd = false;

            if (queryTree is BooleanQueryNode)
            {
                queryTree.Set(actualQueryNodeList);

                return(queryTree);
            }
            else
            {
                return(new BooleanQueryNode(actualQueryNodeList));
            }
        }
        ValueNode ParseValue(Operator? @operator)
        {
            if (@operator == Operator.In)
            {
                return(new ValueNode(new NodeList <Expression>(ParseExpressionList())));
            }

            var expression = ParseExpression();

            if (expression == null)
            {
                throw new Exception();
            }
            return(new ValueNode(new NodeList <Expression> {
                expression
            }));
        }
Exemple #29
0
 public bool Match(BinaryExpression binExp)
 {
     if (binExp.Operator == Operator.IAdd || binExp.Operator == Operator.ISub)
     {
         if (binExp.Left is Cast cLeft && binExp.Right is Cast cRight)
         {
             if (cLeft.DataType == cRight.DataType)
             {
                 this.dt     = cLeft.DataType;
                 this.eLeft  = cLeft.Expression;
                 this.eRight = cRight.Expression;
                 this.op     = binExp.Operator;
                 return(true);
             }
         }
     }
     return(false);
 }
Exemple #30
0
        private void ExistsBase <T>(Operator?oper, Schema <T> schema, bool notExists, params Relation[] columnOn) where T : TfEntity, new()
        {
            string existence = notExists ?
                               "NOT" :
                               string.Empty;

            string customName = "sub";

            var onString = new List <string>();

            foreach (var column in columnOn)
            {
                onString.Add($"{column.Column1.GetCustomName(customName)} {GetCondition(column.Condition ?? Is.EqualTo)} {column.Column2.Get}");
            }

            string statement = $"{existence} EXISTS ({Operations.SELECT} 1 FROM {schema.TableName} AS {customName} WHERE {string.Join(", ", onString)})";

            this.AddWhere(oper, statement);
        }
 /**
  * Constructor.
  *
  * @param pTree  The tree node representing the binary operator expression.
  * @param pOperatorType  One of the 'Operator.???' constants defined by the
  *                       interface '.
  * @param pTokenRewriteStream  The token stream the token of the stated
  *                             tree node belongs to.
  */
 private AST2BinaryOperatorExpression(
     AST2JSOMTree pTree, Operator? pOperatorType,
     TokenRewriteStream pTokenRewriteStream)
     : base(pTree, ExpressionType.BINARY_OPERATOR_EXPRESSION, pTokenRewriteStream)
 {
     mOperatorType = pOperatorType;
 }
 /// <summary>
 /// Sets the boolean operator of the query parser used to parse the query string.
 ///
 /// In default mode ({@link FieldQueryBuilder.Operator#OR}) terms without any modifiers
 /// are considered optional: for example <code>capital of Hungary</code> is equal to
 /// <code>capital OR of OR Hungary</code>.
 ///
 /// In {@link FieldQueryBuilder.Operator#AND} mode terms are considered to be in conjunction: the
 /// above mentioned query is parsed as <code>capital AND of AND Hungary</code>
 /// </summary>
 /// <param name="defaultOperator"></param>
 /// <returns></returns>
 public QueryStringQueryBuilder DefaultOperator(Operator defaultOperator)
 {
     _defaultOperator = defaultOperator;
     return this;
 }
        private void Clear()
        {
            _operandOne = null;
            _operandTwo = null;
            _operation = null;

            DisplayValue = string.Empty;
        }
        private void ClearEntryCommandExecute()
        {
            if (_operandTwo.HasValue)
            {
                _operandTwo = null;
            }
            else
            {
                _operation = null;
                _operandOne = null;
            }

            DisplayValue = string.Empty;
        }
        private void OperatorCommandExecute(string op)
        {
            Operator? operation;

            switch (op)
            {
                case "+":
                    operation = Operator.Addition;
                    break;
                case "-":
                    operation = Operator.Subtraction;
                    break;
                case "*":
                    operation = Operator.Multiplication;
                    break;
                case "/":
                    operation = Operator.Division;
                    break;
                default:
                    throw new ArgumentException("Invalid Operator!");
            }

            if (_operandTwo.HasValue)
            {
                var calculation = Calculate();
                if (calculation != 0)
                {
                    _operandOne = calculation;
                    _operation = operation;

                    DisplayValue = string.Empty;
                }
                else
                {
                    Clear();
                }
            }
            else if (_operandOne.HasValue)
            {
                _operation = operation;
                DisplayValue = string.Empty;
            }
        }
Exemple #36
0
 public Node(Operator op, params Node[] nodes)
 {
     this.nodes = nodes;
     this.op = op;
 }
 /// <summary>
 /// Sets the boolean operator of the query parser used to parse the query string.
 ///
 /// <p>In default mode ({@link FieldQueryBuilder.Operator#OR}) terms without any modifiers
 /// are considered optional: for example <code>capital of Hungary</code> is equal to
 /// <code>capital OR of OR Hungary</code>.</p>
 ///
 /// <p>In {@link FieldQueryBuilder.Operator#AND} mode terms are considered to be in conjunction: the
 /// above mentioned query is parsed as <code>capital AND of AND Hungary</code></p>
 /// </summary>
 /// <param name="defaultOperator"></param>
 /// <returns></returns>
 public FieldQueryBuilder DefaultOperator(Operator defaultOperator)
 {
     _defaultOperator = defaultOperator;
     _extraSet = true;
     return this;
 }