/// <summary> /// Returns true if <paramref name="a"/> and <paramref name="b"/> are equal. /// </summary> /// <param name="a">The first object</param> /// <param name="b">The second object</param> /// <returns>true if <paramref name="a"/> and <paramref name="b"/> are equal.</returns> public static bool AreEqual(FilterExpression a, FilterExpression b) { if (a == null && b == null) { return(true); } if (a != null || b != null) { return(false); } if (a.Equals(b)) { return(true); } if (!AreEqual(a.Conditions, b.Conditions)) { return(false); } if (a.FilterOperator != b.FilterOperator) { return(false); } if (!AreEqual(a.Filters, b.Filters)) { return(false); } if (a.IsQuickFindFilter != b.IsQuickFindFilter) { return(false); } return(true); }
public Filter CreateFilter() { var expression = new FilterExpression(); var dataType = PropertyTypes.Parse(_dataType); var value = Convert.ChangeType(_value, dataType); if (dataType == typeof(int)) { return(expression.Equals(_field, (int)value)); } if (dataType == typeof(string)) { return(expression.Equals(_field, (string)value)); } if (dataType == typeof(DateTime)) { return(expression.Equals(_field, (DateTime)value)); } throw new NotSupportedException("Unsupported data type: " + _dataType); }
public Property Equals_should_be_commutative(NonNull <DurationExpression> first, FilterExpression second) => (first.Item.Equals(second) == second.Equals(first.Item)).ToProperty();