Beispiel #1
0
        internal static BinaryExpression ApplyCompareOperation(
            ComparatorType comparatorType,
            Expression getValueExp,
            Expression getFilterExp)
        {
            switch (comparatorType)
            {
            case ComparatorType.Equal:
                return(Expression.Equal(getValueExp, getFilterExp));

            case ComparatorType.GreaterThanOrEqual:
                return(Expression.GreaterThanOrEqual(getValueExp, getFilterExp));

            case ComparatorType.GreaterThan:
                return(Expression.GreaterThan(getValueExp, getFilterExp));

            case ComparatorType.LessThan:
                return(Expression.LessThan(getValueExp, getFilterExp));

            case ComparatorType.LessThanOrEqual:
                return(Expression.LessThanOrEqual(getValueExp, getFilterExp));

            default:
                goto case ComparatorType.Equal;
            }
        }
Beispiel #2
0
        public override void UpdatePersistentData()
        {
            _propertyNamePers    = null;
            _comparatorPers      = ComparatorType.Equals;
            _targetValuePers     = null;
            _methodParameterPers = null;

            // Save property name, not index
            if (_propertyIndex < PropertyList.Length)
            {
                _propertyNamePers = PropertyList[_propertyIndex];
            }
            _comparatorPers = _comparator;
            // Target value
            if (_targetValue != null)
            {
                _targetValuePers = _targetValue.ValueStr;
            }
            // Parameters
            if (_methodParameter != null)
            {
                _methodParameterPers = new string[_methodParameter.Length];
                for (int i = 0; i < _methodParameter.Length; i++)
                {
                    _methodParameterPers[i] = _methodParameter[i].ValueStr;
                }
            }
        }
Beispiel #3
0
        public bool CompareFrom(object other, ComparatorType ope)
        {
            switch (ope)
            {
            case ComparatorType.Equals:
                return(_value.Equals(other));

            case ComparatorType.NotEquals:
                return(!_value.Equals(other));

            case ComparatorType.Less:
                return(_comparable ? ((_value as IComparable).CompareTo(other) > 0) : false);

            case ComparatorType.LessOrEquals:
                return(_comparable ? ((_value as IComparable).CompareTo(other) >= 0) : false);

            case ComparatorType.More:
                return(_comparable ? ((_value as IComparable).CompareTo(other) < 0) : false);

            case ComparatorType.MoreOrEquals:
                return(_comparable ? ((_value as IComparable).CompareTo(other) <= 0) : false);

            default:
                return(false);
            }
        }
Beispiel #4
0
 public TriggerConditionFlight(VesselTriggers vesselTriggers) : base(vesselTriggers)
 {
     _type            = TriggerConditionType.Flight;
     _propertyIndex   = -1;
     _fieldInfo       = null;
     _propertyInfo    = null;
     _methodInfo      = null;
     _propertySource  = null;
     _methodParameter = null;
     _comparator      = ComparatorType.Equals;
     _targetValue     = null;
 }
Beispiel #5
0
        public static IComparator GetComparator(ComparatorType type)
        {
            switch (type)
            {
            case ComparatorType.CharByCharComparator:
                return(new CharByCharComparator());

            case ComparatorType.ContainsComparator:
                return(new ContainsComparator());

            case ComparatorType.EditDistanceComparator:
                return(new EditDistanceComparator());
            }
            return(null);
        }
Beispiel #6
0
        public DataTable GetResultComparisonByType(ComparatorType type, DataTable fromDataTable, DataTable withDataTable, bool distinct)
        {
            switch (type)
            {
            case ComparatorType.Different:
                return(GetBetweenDifferentData(fromDataTable, withDataTable, distinct));

            case ComparatorType.Equals:
                return(GetBetweenEqualData(fromDataTable, withDataTable, distinct));

            case ComparatorType.Merge:
                return(GetMergeData(fromDataTable, withDataTable, distinct));

            default:
                throw new NotImplementedException();
            }
        }
        private Dictionary <string, QueryColumn> GetFilterInfo(int filterTargetId, SqlConnection connection, string[] queryWords)
        {
            Dictionary <string, QueryColumn> dict = new Dictionary <string, QueryColumn>(); // key - queryWord
            string     qwords = FormatQueryWords(queryWords);
            string     q      = $"Select f.QueryWord, f.FilterColumnName, f.Comparator from [dbo].[Filters] as f where f.FilterTargetId = {filterTargetId} and f.QueryWord in ({qwords})";
            SqlCommand cmd2   = new SqlCommand(q, connection);

            using (SqlDataReader dr = cmd2.ExecuteReader())
            {
                while (dr.Read())
                {
                    ComparatorType comparator = (ComparatorType)Enum.Parse(typeof(ComparatorType), (string)dr["Comparator"], true);
                    dict.Add(dr["QueryWord"].ToString(), new QueryColumn(dr["FilterColumnName"].ToString(), comparator));
                }
            }
            return(dict);
        }
 public static String ComparatorTypeToString(ComparatorType comparatorType)
 {
     switch (comparatorType)
     {
         case ComparatorType.LessThan:
             return "<";
             break;
         case ComparatorType.GreaterThan:
             return ">";
             break;
         case ComparatorType.LessThanOrEqualThan:
             return "<=";
             break;
         case ComparatorType.GreaterThanOrEqualTo:
             return ">=";
             break;
         case ComparatorType.Equals:
             return "=";
             break;
         case ComparatorType.NotEqualTo:
             return "<>";
             break;
         case ComparatorType.Between:
             return "BETWEEN";
             break;
         case ComparatorType.NotBetween:
             return "NOT BETWEEN";
             break;
         case ComparatorType.Like:
             return "LIKE";
             break;
         case ComparatorType.NotLike:
             return "NOT LIKE";
             break;
         case ComparatorType.In:
             return "IN";
             break;
         case ComparatorType.NotIn:
             return "NOT IN";
             break;
         default:
             throw new ArgumentOutOfRangeException("comparatorType");
     }
 }
 public SeedComparatorType(ComparatorType t)
 {
     switch (t)
     {
     case ComparatorType.MinimizeExitDepth:
         comparison = delegate(int bestSeed, int newSeed)
         {
             int d = Util.GetExitDepth();
             if (bestDepth < d)
             {
                 int r = d - bestDepth;
                 bestDepth = d;
                 return(r);
             }
             return(d - bestDepth);
         };
         break;
     }
 }
Beispiel #10
0
 public TriggerConditionFlight(TriggerConditionFlight other) : base(other)
 {
     _type = TriggerConditionType.Flight;
     // Automatic call of PropertyIndex_set
     PropertyIndex = other._propertyIndex;
     _comparator   = other._comparator;
     if (other._targetValue != null)
     {
         _targetValue.ValueStr = other._targetValue.ValueStr;
     }
     if (_methodParameter != null)
     {
         for (int i = 0; i < _methodParameter.Length; i++)
         {
             _methodParameter[i].ValueStr = other._methodParameter[i].ValueStr;
         }
     }
     UpdatePersistentData();
 }
Beispiel #11
0
 public TriggerConditionPart(TriggerConditionPart other) : base(other)
 {
     _type = TriggerConditionType.Part;
     _part = null;
     // Automatic call of Part_set
     ConditionPart = other._part;
     // Automatic call of PropertyIndex_set
     PropertyIndex = other._propertyIndex;
     _comparator   = other._comparator;
     if ((_targetValue != null) && other._targetValue != null)
     {
         _targetValue.ValueStr = other._targetValue.ValueStr;
     }
     if (_methodParameter != null)
     {
         for (int i = 0; i < _methodParameter.Length; i++)
         {
             _methodParameter[i].ValueStr = other._methodParameter[i].ValueStr;
         }
     }
     _currentValue = null;
     UpdatePersistentData();
 }
Beispiel #12
0
 public TermsFacetBuilder Order(ComparatorType type)
 {
     _comparatorType = type;
     return(this);
 }
Beispiel #13
0
 public TermsFacetBuilder(string name) : base(name)
 {
     _comparatorType = ComparatorType.COUNT;
 }
Beispiel #14
0
 protected Comparator(ComparatorType comparatorType)
 {
     ComparatorType = comparatorType;
 }
Beispiel #15
0
 public QueryColumn(string columnName, ComparatorType comparator)
 {
     ColumnName = columnName;
     Comparator = comparator;
 }
Beispiel #16
0
 public TermsFacetBuilder(string name)
     : base(name)
 {
     _comparatorType = ComparatorType.COUNT;
 }
Beispiel #17
0
 public TermsFacetBuilder Order(ComparatorType type)
 {
     _comparatorType = type;
     return this;
 }
Beispiel #18
0
 protected Comparator(ComparatorType comparatorType)
 {
     ComparatorType = comparatorType;
 }
Beispiel #19
0
 /// <summary>
 /// Creates a Comparator object using the specified ComparatorType.
 /// </summary>
 /// <param name="comparatorType">The type of compare operation this Comparator object is to perform.</param>
 internal Comparator( ComparatorType comparatorType )
 {
     _comparatorType = comparatorType;
     NumberOfParameters = 2;
 }
Beispiel #20
0
 public bool ComparatorValid(ComparatorType ope)
 {
     return(_comparable || (ope == ComparatorType.Equals) || (ope == ComparatorType.NotEquals));
 }