protected override bool Compare(decimal x, decimal y) { var caster = new NumericCaster(); var z = caster.Execute(secondOperand); return(x % z == y); }
protected internal object FormatValue(ColumnType columnType, object value) { object v = null; if (columnType == ColumnType.Numeric) { v = new NumericCaster().Execute(value); } else if (columnType == ColumnType.DateTime) { v = new DateTimeCaster().Execute(value); } else if (columnType == ColumnType.Boolean) { v = new ThreeStateBooleanCaster().Execute(value); } else { if (value is IConvertible) { v = ((IConvertible)value).ToString(CultureInfo.InvariantCulture); } else { v = value.ToString(); } } return(v); }
protected override bool Apply(object x) { var caster = new NumericCaster(); var numX = caster.Execute(x); return(numX % 1 == 0); }
public NumericToRound(string digits) { var caster = new NumericCaster(); var d = caster.Execute(digits); Digits = Math.Truncate(d) == d?Convert.ToInt32(Math.Truncate(d)) : throw new ArgumentException(); }
public NumericToClip(string min, string max) { var caster = new NumericCaster(); Min = caster.Execute(min); Max = caster.Execute(max); }
protected override bool ApplyWithReference(object reference, object x) { var caster = new NumericCaster(); var numX = caster.Execute(x); var numY = caster.Execute(reference); return(Compare(numX, numY)); }
protected override bool Apply(object x) { var builder = new NumericIntervalBuilder(Reference); builder.Build(); var interval = builder.GetInterval(); var caster = new NumericCaster(); var numX = caster.Execute(x); return(interval.Contains(numX)); }
private object EvaluateUncasted(object value) { if (value as string == "(null)") { EvaluateNull(); } var caster = new NumericCaster(); var numeric = caster.Execute(value); return(EvaluateNumeric(numeric)); }
public object Evaluate(object value) { if (value == null || DBNull.Value.Equals(value) || value as string == "(empty)" || value as string == "(null)" || value is string && string.IsNullOrEmpty(value as string)) { return(null); } else { var caster = new NumericCaster(); var numeric = caster.Execute(value); return(Truncate(numeric)); } }
protected override bool ApplyWithReference(object reference, object x) { var builder = new NumericIntervalBuilder(reference); builder.Build(); if (!builder.IsValid()) { throw builder.GetException(); } var interval = builder.GetInterval(); var caster = new NumericCaster(); var numX = caster.Execute(x); return(interval.Contains(numX)); }
private Decimal?CastToNumeric(object obj) { if (obj == null) { return(null); } var caster = new NumericCaster(); if (caster.IsValid(obj)) { return(caster.Execute(obj)); } throw new ArgumentException(); }
protected void CheckSettingsFirstRowCell(ColumnRole columnRole, ColumnType columnType, DataColumn dataColumn, object value, string[] messages) { var columnName = dataColumn.ColumnName; if (!DBNull.Value.Equals(value)) { if (columnRole != ColumnRole.Ignore) { if (columnType == ColumnType.Numeric && IsNumericField(dataColumn)) { return; } var numericCaster = new NumericCaster(); if (columnType == ColumnType.Numeric && !(numericCaster.IsValid(value) || BaseComparer.IsValidInterval(value))) { var exception = string.Format(messages[0] , columnName, value.ToString()); if (numericCaster.IsValid(value.ToString().Replace(",", "."))) { exception += messages[1]; } throw new EquivalerException(exception); } if (columnType == ColumnType.DateTime && IsDateTimeField(dataColumn)) { return; } if (columnType == ColumnType.DateTime && !BaseComparer.IsValidDateTime(value.ToString())) { throw new EquivalerException( string.Format(messages[2] , columnName, value.ToString())); } } } }