/// <summary>
        /// The Compare.
        /// </summary>
        /// <param name="term">The term<see cref="FilterTerm"/>.</param>
        /// <returns>The <see cref="bool"/>.</returns>
        public bool Compare(FilterTerm term)
        {
            if (RubricName != term.RubricName)
            {
                return(false);
            }
            if (!Value.Equals(term.Value))
            {
                return(false);
            }
            if (!Operand.Equals(term.Operand))
            {
                return(false);
            }
            if (!Stage.Equals(term.Stage))
            {
                return(false);
            }
            if (!Logic.Equals(term.Logic))
            {
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// The Clone.
        /// </summary>
        /// <returns>The <see cref="object"/>.</returns>
        public object Clone()
        {
            FilterTerm clone = (FilterTerm)this.MemberwiseClone();

            clone.FilterRubric = FilterRubric;
            return(clone);
        }
        /// <summary>
        /// The Clone.
        /// </summary>
        /// <param name="value">The value<see cref="object"/>.</param>
        /// <returns>The <see cref="FilterTerm"/>.</returns>
        public FilterTerm Clone(object value)
        {
            FilterTerm clone = (FilterTerm)this.MemberwiseClone();

            clone.FilterRubric = FilterRubric;
            clone.Value        = value;
            return(clone);
        }
예제 #4
0
        private Expression <Func <IFigure, bool> > CaseConditioner(FilterTerm fc, Expression <Func <IFigure, bool> > ex)
        {
            if (fc.Value != null)
            {
                object      Value   = fc.Value;
                OperandType Operand = fc.Operand;
                if (Operand != OperandType.Like && Operand != OperandType.NotLike)
                {
                    switch (Operand)
                    {
                    case OperandType.Equal:

                        ex = (r => r[fc.FilterRubric.FieldId] != null ?
                              fc.FilterRubric.RubricType == typeof(IUnique) ||
                              fc.FilterRubric.RubricType == typeof(string) ||
                              fc.FilterRubric.RubricType == typeof(DateTime) ?
                              r[fc.FilterRubric.FieldId].ComparableUInt64(fc.FilterRubric.RubricType)
                              .Equals(Value.ComparableUInt64(fc.FilterRubric.RubricType)) :
                              r[fc.FilterRubric.FieldId].ComparableDouble(fc.FilterRubric.RubricType)
                              .Equals(Value.ComparableDouble(fc.FilterRubric.RubricType)) :
                              false);
                        break;

                    case OperandType.EqualOrMore:

                        ex = (r => r[fc.FilterRubric.FieldId] != null ?
                              fc.FilterRubric.RubricType == typeof(IUnique) ||
                              fc.FilterRubric.RubricType == typeof(string) ||
                              fc.FilterRubric.RubricType == typeof(DateTime) ?
                              r[fc.FilterRubric.FieldId].ComparableUInt64(fc.FilterRubric.RubricType)
                              >=
                              (Value.ComparableUInt64(fc.FilterRubric.RubricType)) :
                              r[fc.FilterRubric.FieldId].ComparableDouble(fc.FilterRubric.RubricType)
                              >=
                              (Value.ComparableDouble(fc.FilterRubric.RubricType)) : false);
                        break;

                    case OperandType.More:

                        ex = (r => r[fc.FilterRubric.FieldId] != null ?
                              fc.FilterRubric.RubricType == typeof(IUnique) ||
                              fc.FilterRubric.RubricType == typeof(string) ||
                              fc.FilterRubric.RubricType == typeof(DateTime) ?
                              r[fc.FilterRubric.FieldId].ComparableUInt64(fc.FilterRubric.RubricType)
                              >
                              (Value.ComparableUInt64(fc.FilterRubric.RubricType)) :
                              r[fc.FilterRubric.FieldId].ComparableDouble(fc.FilterRubric.RubricType)
                              >
                              (Value.ComparableDouble(fc.FilterRubric.RubricType)) : false);
                        break;

                    case OperandType.EqualOrLess:

                        ex = (r => r[fc.FilterRubric.FieldId] != null ?
                              fc.FilterRubric.RubricType == typeof(IUnique) ||
                              fc.FilterRubric.RubricType == typeof(string) ||
                              fc.FilterRubric.RubricType == typeof(DateTime) ?
                              r[fc.FilterRubric.FieldId].ComparableUInt64(fc.FilterRubric.RubricType)
                              <=
                              (Value.ComparableUInt64(fc.FilterRubric.RubricType)) :
                              r[fc.FilterRubric.FieldId].ComparableDouble(fc.FilterRubric.RubricType)
                              <=
                              (Value.ComparableDouble(fc.FilterRubric.RubricType)) : false);
                        break;

                    case OperandType.Less:

                        ex = (r => r[fc.FilterRubric.FieldId] != null ?
                              fc.FilterRubric.RubricType == typeof(IUnique) ||
                              fc.FilterRubric.RubricType == typeof(string) ||
                              fc.FilterRubric.RubricType == typeof(DateTime) ?
                              r[fc.FilterRubric.FieldId].ComparableUInt64(fc.FilterRubric.RubricType)
                              <
                              (Value.ComparableUInt64(fc.FilterRubric.RubricType)) :
                              r[fc.FilterRubric.FieldId].ComparableDouble(fc.FilterRubric.RubricType)
                              <
                              (Value.ComparableDouble(fc.FilterRubric.RubricType)) : false);
                        break;

                    default:
                        break;
                    }
                }
                else if (Operand != OperandType.NotLike)
                {
                    ex = (r => r[fc.FilterRubric.FieldId] != null ?
                          Convert.ChangeType(r[fc.FilterRubric.FieldId], fc.FilterRubric.RubricType).ToString()
                          .Contains(Convert.ChangeType(Value, fc.FilterRubric.RubricType).ToString()) :
                          false);
                }
                else
                {
                    ex = (r => r[fc.FilterRubric.FieldId] != null ?
                          !Convert.ChangeType(r[fc.FilterRubric.FieldId], fc.FilterRubric.RubricType).ToString()
                          .Contains(Convert.ChangeType(Value, fc.FilterRubric.RubricType).ToString()) :
                          false);
                }
            }
            return(ex);
        }