Exemple #1
0
        /// <summary>
        /// Base constructor
        /// </summary>
        /// <param name="name"></param>
        /// <param name="op"></param>
        /// <param name="value"></param>
        public FilterBase(string name, EOperator op, object value)
        {
            this.mName     = name;
            this.mOperator = op;
            this.mValue    = value;

            switch (this.mOperator)
            {
            case EOperator.In:
                this.checkValueArray("IN", value as object[], 1, 9999);
                break;

            case EOperator.Between:
                this.checkValueArray("BETWEEN", value as object[], 2, 2);
                break;

            case EOperator.IsNull:
                this.checkValueNull("ISNULL", value);
                break;

            case EOperator.IsNotNull:
                this.checkValueNull("ISNOTNULL", value);
                break;

            case EOperator.Equal:
            case EOperator.Differs:
                break;

            default:
                this.checkValueNotNull(this.mOperator.ToString().ToUpper(), value);
                break;
            }
        }
    public void Operate(EOperator op, float value, object context)
    {
        float newValue = _currentValue;

        switch (op)
        {
        case EOperator.Set:
            newValue = value;
            break;

        case EOperator.Add:
            newValue += value;
            break;

        case EOperator.Sub:
            newValue -= value;
            break;

        case EOperator.Mult:
            newValue *= value;
            break;

        case EOperator.Div:
            newValue /= value;
            break;

        default:
            Debug.Assert(false, "Unknown enum: " + op);
            break;
        }

        SetValueIntern(newValue, value, op, context);
    }
    private void SetValueIntern(float newValue, float operatorValue, EOperator op, object context)
    {
        float oldValue = _currentValue;

        _currentValue = newValue;


        ValueChangedEvent.InvokeEvent(new EventArgs(oldValue, _currentValue, this));
    }
Exemple #4
0
        /// <summary>
        /// Create the SuperOffice restriction
        /// </summary>
        /// <param name="fullColumnName">Column name including table (dot syntax)</param>
        /// <param name="op">Operator to compare value</param>
        /// <param name="interRestrictionOperator">And / Or</param>
        /// <param name="level">Level of the restriction (for parenthesis). This corrosponds directly with the InterParenthesis value of a SuperOffice ArchiveRestrictionInfo</param>
        /// <param name="values">Value(s) for column comparison in restriction</param>
        /// <returns>Newly created archive restriction info</returns>
        protected ArchiveRestrictionInfo CreateRestriction(string fullColumnName, EOperator op, InterRestrictionOperator interRestrictionOperator, int level, params object[] values)
        {
            ArchiveRestrictionInfo r = new ArchiveRestrictionInfo();

            r.Name             = fullColumnName;
            r.Operator         = op.ToString().ToLower();
            r.Values           = ConvertValues(values);
            r.InterParenthesis = level;
            r.IsActive         = true;

            SetPrevInterRestrictionOperator(interRestrictionOperator);

            return(r);
        }
Exemple #5
0
        public NumericEquation(List <string> fields)
        {
            bool strongOperatorFound   = false;
            int  operatorPosition      = fields.Count();
            int  parenthesisScopeCount = 0;

            for (int i = fields.Count() - 1; i >= 0; --i)
            {
                if (fields[i] == ")")
                {
                    ++parenthesisScopeCount;
                }
                else if (fields[i] == "(")
                {
                    --parenthesisScopeCount;
                }
                else if (parenthesisScopeCount == 0)
                {
                    if (fields[i] == "+" || fields[i] == "-")
                    {
                        operatorPosition = i;
                        break;
                    }
                    if (!strongOperatorFound && (fields[i] == "*" || fields[i] == "/"))
                    {
                        strongOperatorFound = true;
                        operatorPosition    = i;
                    }
                }
            }
            left  = fields.GetRange(0, operatorPosition);
            right = fields.GetRange(operatorPosition + 1, fields.Count() - 1 - operatorPosition);
            if (fields[operatorPosition] == "+")
            {
                ope = EOperator.Add;
            }
            else if (fields[operatorPosition] == "-")
            {
                ope = EOperator.Sub;
            }
            else if (fields[operatorPosition] == "*")
            {
                ope = EOperator.Mul;
            }
            else if (fields[operatorPosition] == "/")
            {
                ope = EOperator.Div;
            }
        }
Exemple #6
0
        internal static Func <object, object, bool> GetByEnum(EOperator function)
        {
            switch (function)
            {
            case EOperator.EqualTo:
                return(EqualTo);

            case EOperator.NotEqualTo:
                return(NotEqualTo);

            default:
                break;
            }
            throw new NotImplementedException();
        }
Exemple #7
0
        /// <summary>
        /// Ritorna stringa con stringa operatore
        /// </summary>
        /// <param name="op"></param>
        /// <returns></returns>
        internal static string OperatorToString(EOperator op)
        {
            switch (op)
            {
            case EOperator.Equal:
                return(@"=");

            case EOperator.Differs:
                return(@"<>");

            case EOperator.GreaterThan:
                return(@">");

            case EOperator.GreaterEquals:
                return(@">=");

            case EOperator.LessThan:
                return(@"<");

            case EOperator.LessEquals:
                return(@"<=");

            case EOperator.Like:
                return(@" LIKE ");

            case EOperator.NotLike:
                return(@" NOT LIKE ");

            case EOperator.IsNull:
                return(@" IS NULL ");

            case EOperator.IsNotNull:
                return(@" IS NOT NULL ");

            case EOperator.In:
                return(@" IN ");

            case EOperator.Between:
                return(@" BETWEEN ");

            default:
                throw new ArgumentException("Operatore sconosciuto");
            }
        }
        static void Main(string[] args)
        {
            Console.Write("num1: ");
            int num1 = int.Parse(Console.ReadLine());

            Console.Write("num2: ");
            int num2 = int.Parse(Console.ReadLine());

            Console.Write("operation(+, -, *, /, %): ");
            char operationChar = char.Parse(Console.ReadLine());

            EOperator operation = (EOperator)operationChar;



            switch (operation)
            {
            case EOperator.Plus:
                Console.WriteLine(num1 + num2);
                break;

            case EOperator.Minus:
                Console.WriteLine(num1 - num2);
                break;

            case EOperator.Multiply:
                Console.WriteLine(num1 * num2);
                break;

            case EOperator.Divide:
                Console.WriteLine(num1 / num2);
                break;

            case EOperator.Mod:
                Console.WriteLine(num1 % num2);
                break;

            default:
                Console.WriteLine($"You entered a wrong operator: {operationChar}");
                break;
            }
        }
Exemple #9
0
 protected void AddRestriction(string fullColumnName, EOperator op, InterRestrictionOperator interRestrictionOperator, int level, params object[] values)
 {
     AddRestriction(CreateRestriction(fullColumnName, op, interRestrictionOperator, level, values));
 }
Exemple #10
0
 /// <summary>
 /// Esegue ricerca oggetti a partire da un valore di colonna applicando l'operatore impostato
 /// </summary>
 /// <param name="columnName"></param>
 /// <param name="op">Se [IsNull, IsNotNull] il valore non viene considerato</param>
 /// <param name="value"></param>
 /// <returns></returns>
 public TL SearchByColumn(string columnName, EOperator op, object value)
 {
     return((TL)this.searchByColumn(new Filter(columnName, op, value)));
 }
Exemple #11
0
        public void Add(string property, EOperator op, int level, InterRestrictionOperator interOperator, object value)
        {
            string column = DynamicPropertyHelper.GetColumnName <T>(property);

            AddRestriction <T>(column, op, interOperator, level, value);
        }
Exemple #12
0
 private StringRestrictionBuilder Add(string column, EOperator op, InterRestrictionOperator andOr, int level, params object[] values)
 {
     AddRestriction(column, op, andOr, level, values);
     return(this);
 }
Exemple #13
0
 public ExprExpr(IQueryExpression exp1, EOperator op, IQueryExpression exp2)
     : base(exp1, SqlQuery.Precedence.Comparison)
 {
     EOperator = op;
     Expr2     = exp2;
 }
Exemple #14
0
 public StringRestrictionBuilder Or(string column, EOperator op, params object[] values)
 {
     return(Add(column, op, InterRestrictionOperator.Or, 0, values));
 }
Exemple #15
0
 internal Operator(IExpr <T1, T2> expr, EOperator op)
 {
     _expr = expr;
     _op   = op;
 }
 public RequiredIfAttribute(String propertyName, Object desiredvalue, EOperator function = EOperator.EqualTo)
 {
     PropertyName = propertyName;
     DesiredValue = desiredvalue;
     Function     = Operators.GetByEnum(function);
 }
Exemple #17
0
        private static string BuildFilterStringItem(EFilterType FilterItemType, string Name, EConnection Connection, EFunction Function, EOperator Operator, string ValueType, string Value, string Value1Type, string Value1, string Value2Type, string Value2)
        {
            StringBuilder current = new StringBuilder();

            current.Append("{");
            current.Append("" + Name + ":{");
            current.Append($"{ Operator.ToString().ToLower()}" + ":{");
            if (FilterItemType == EFilterType.MultiValue)
            {
                current.AppendFormat("Value1Type:\"{0}\",", Value1Type);
                current.AppendFormat("Value1:\"{0}\",", Value1);
                current.AppendFormat("Value2Type:\"{0}\",", Value2Type);
                current.AppendFormat("Value2:\"{0}\"", Value2);
            }
            else
            {
                current.AppendFormat("ValueType:\"{0}\",", ValueType);
                current.AppendFormat("Value:\"{0}\"", Value);
            }
            current.Append("}");
            current.Append("}");
            current.Append("}");
            return(current.ToString());
        }
Exemple #18
0
 /// <summary>
 /// Costruttore base
 /// </summary>
 /// <param name="propName"></param>
 /// <param name="op"></param>
 /// <param name="propValue"></param>
 public Filter(string fieldName, EOperator op, object fieldValue)
     : base(fieldName, op, fieldValue)
 {
 }
Exemple #19
0
 /// <summary>
 /// Filtro OR con parametri espliciti
 /// </summary>
 /// <param name="name"></param>
 /// <param name="op"></param>
 /// <param name="value"></param>
 /// <returns></returns>
 public IFilter Or(string name, EOperator op, object value)
 {
     return(this.Or(new Filter(name, op, value)));
 }
Exemple #20
0
 protected void AddRestriction <T>(string column, EOperator op, InterRestrictionOperator interRestrictionOperator, int level, params object[] values)
 {
     AddRestriction(CreateRestriction <T>(column, op, interRestrictionOperator, level, values));
 }
Exemple #21
0
        protected ArchiveRestrictionInfo CreateRestriction <T>(string column, EOperator op, InterRestrictionOperator interRestrictionOperator, int level, params object[] values)
        {
            string fullColumnName = DynamicPropertyHelper.GetFullDotSyntaxColumnName <T>(column);

            return(CreateRestriction(fullColumnName, op, interRestrictionOperator, level, values));
        }
Exemple #22
0
        public BehaviourConditionalNode(Hashtable options, IBehaviourEmployee employee)
            : base(employee)
        {
            if (options == null)
            {
                return;
            }

            string conditionsString = options["condition"] as string;

            if (!String.IsNullOrEmpty(conditionsString))
            {
                string[] conditions = conditionsString.Split('|');
                for (int i = 0; i < conditions.Length; i++)
                {
                    string temp = conditions[i];

                    if (temp == null || temp == string.Empty)
                    {
                        continue;
                    }

                    // 試圖切割字符串,查看其是表達式還是函數
                    string[] condition = Regex.Split(conditions[i].Trim(), mSplitRegularPattern, RegexOptions.None);

                    if (condition.Length == 1)
                    {
                        Condition con = new Condition();
                        con.IsNot = false;

                        // 先判断是否取反
                        string method    = condition[0];
                        char   firstChar = method[0];

                        if (firstChar == '!')
                        {
                            con.IsNot = true;
                            method    = method.Substring(1, method.Length - 1);
                        }

                        //                     MethodInfo functor = objType.GetMethod(method);
                        //
                        //                     if (functor == null)
                        //                     {
                        //                         GameDebug.LogError(string.Format("{0} Conditional::Conditional can not get method:{1}", _Comment,  method));
                        //                     }

                        con.FunctorByString = method;
                        //con._Functor = functor;
                        con.Type = EConditionType.Function;

                        mConditions.AddLast(con);
                    }
                    else if (condition.Length >= 5)
                    {
                        Condition con = new Condition();
                        con.Type       = EConditionType.Expression;
                        con.LeftValue  = condition[1];
                        con.Operator   = condition[2];
                        con.RightValue = condition[3];

                        mConditions.AddLast(con);
                    }
                    else
                    {
                        // Error
                        //GameDebug.LogError("Conditional::Conditional unknown string:" + conditionsString);
                    }
                }
            }

            Hashtable table = options["true"] as Hashtable;

            mTrueBehavior = BehaviourNode.CreateNode(table, employee);

            table          = options["false"] as Hashtable;
            mFalseBehavior = BehaviourNode.CreateNode(table, employee);

            string operatorString = options["operator"] as string;

            if (operatorString != null && operatorString.ToLower() == "or")
            {
                mOperator = EOperator.Or;
            }
            else
            {
                mOperator = EOperator.And;
            }

            // 解析调用参数
            base.ParseParamters(options);

            // 解析缓冲模式
            string cacheModeString = options["cache"] as string;

            if (cacheModeString != null && cacheModeString.ToLower() == "true")
            {
                mIsCacheTurnOn = true;
            }
            else
            {
                mIsCacheTurnOn = false;
            }

            if (mIsCacheTurnOn)
            {
                string refreshTimeString = options["refresh"] as string;

                if (refreshTimeString == null)
                {
                    mIsCacheTurnOn = false;
                    return;
                }

                string[] timesStr = refreshTimeString.Split('~');

                if (timesStr.Length > 1)
                {
                    float begin = (float)(Convert.ToDouble(timesStr[0]));
                    float end   = (float)(Convert.ToDouble(timesStr[1]));

                    mConstRefreshTime = UnityEngine.Random.Range(begin, end);
                }
                else
                {
                    mConstRefreshTime = (float)(Convert.ToDouble(refreshTimeString));
                }
            }
        }