public virtual bool Validate(DataRow dataRow, int columnIndex) { IComparable comparable = dataRow[columnIndex] as IComparable; if (this.Operand == null || comparable == null) { return(false); } if (comparable.GetType() != this.Operand.GetType()) { if (OperationComparer.IsNumeric(comparable) && OperationComparer.IsNumeric(this.Operand)) { return(true); } SharedObject.Instance.Output(SharedObject.enOutputType.Error, "FilterTypeWarning operand:" + this.Operand.GetType() + "comparable:" + comparable.GetType()); return(false); } else { if (comparable is string) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "FilterTypeWarning operand:" + this.Operand.GetType() + "comparable:" + comparable.GetType()); return(false); } return(true); } }
public static bool Compare(IComparable operand1, IComparable operand2, Func <IComparable, IComparable, bool> compareFunc) { if (operand1 == null || operand2 == null) { return(false); } if (!OperationComparer.IsNumeric(operand1) || !OperationComparer.IsNumeric(operand2)) { return(compareFunc(operand1, operand2)); } Type type = operand1.GetType(); Type type2 = operand2.GetType(); int num; int num2; if (!OperationComparer._typePrecedence.TryGetValue(type, out num) || !OperationComparer._typePrecedence.TryGetValue(type2, out num2)) { return(compareFunc(operand1, operand2)); } if (num < num2) { object obj; if (!OperationComparer.TryConvertOperand(operand1, type2, out obj)) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "FilterTypeWarning operand:" + operand1 + "type:" + type2); return(false); } return(compareFunc((IComparable)obj, operand2)); } else { if (num <= num2) { object obj2; OperationComparer.TryConvertOperand(operand1, typeof(double), out obj2); object obj3; OperationComparer.TryConvertOperand(operand2, typeof(double), out obj3); return(compareFunc((IComparable)obj2, (IComparable)obj3)); } object obj4; if (!OperationComparer.TryConvertOperand(operand2, type, out obj4)) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "FilterTypeWarning operand:" + operand1 + "type:" + type2); return(false); } return(compareFunc(operand1, (IComparable)obj4)); } }
public new static bool Equals(object operand1, object operand2) { if (operand1 == null && operand2 == null) { return(true); } if (operand1 == null || operand2 == null) { return(false); } if (!OperationComparer.IsNumeric(operand1) && !OperationComparer.IsNumeric(operand2)) { return(operand1.Equals(operand2)); } Type type = operand1.GetType(); Type type2 = operand2.GetType(); int num; int num2; if (!OperationComparer._typePrecedence.TryGetValue(type, out num) || !OperationComparer._typePrecedence.TryGetValue(type2, out num2)) { return(operand1.Equals(operand2)); } if (num < num2) { object obj; if (!OperationComparer.TryConvertOperand(operand1, type2, out obj)) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "FilterTypeWarning operand:" + operand1 + "type:" + type2); return(false); } return(operand2.Equals(obj)); } else { if (num <= num2) { return(operand1.Equals(operand2)); } object obj2; if (!OperationComparer.TryConvertOperand(operand2, type, out obj2)) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "FilterTypeWarning operand:" + operand1 + "type:" + type2); return(false); } return(operand1.Equals(obj2)); } }
public bool Validate(DataRow leftRow, int column1Index, DataRow rightRow, int column2Index) { object obj = leftRow[column1Index]; object obj2 = rightRow[column2Index]; return((obj == null && obj2 == null) || (obj != null && obj2 != null && (obj.GetType() == obj2.GetType() || (OperationComparer.IsNumeric(obj) && OperationComparer.IsNumeric(obj2))))); }
public bool Validate(DataRow dataRow, int columnIndex) { object obj = dataRow[columnIndex]; return((this.Operand == null && obj == null) || (this.Operand != null && obj != null && (obj.GetType() == this.Operand.GetType() || (OperationComparer.IsNumeric(obj) && OperationComparer.IsNumeric(this.Operand))))); }