Exemple #1
0
        protected override ComparerResult CompareObjects(object x, object y, Tolerance tolerance)
        {
            if (!(tolerance is DateTimeTolerance))
                throw new ArgumentException("Tolerance must be of type 'DateTimeTolerance'");

            return CompareObjects(x, y, (DateTimeTolerance)tolerance);
        }
 private string GetToleranceText(Tolerance tolerance)
 {
     var toleranceText = string.Empty;
     if (tolerance != null)
         toleranceText += string.Format(" (+/- {0}) ", tolerance.ValueString);
     return toleranceText;
 }
Exemple #3
0
        public ComparerResult Compare(object x, object y, Tolerance tolerance)
        {
            var eq = CompareBasic(x, y);
            if (eq != null)
                return eq;

            return CompareObjects(x, y, tolerance);
        }
        public virtual string GetText(ColumnRole role, ColumnType type, Tolerance tolerance, Rounding rounding)
        {
            var roleText = GetRoleText(role);
            var typeText = GetTypeText(type);
            var toleranceText = GetToleranceText(tolerance);
            var roundingText = GetRoundingText(rounding);

            var value = string.Format("{0} ({1}){2}{3}{4}", roleText, typeText, (toleranceText + roundingText).Length > 0 ? " " : "", toleranceText, roundingText);

            return value;
        }
Exemple #5
0
 protected abstract ComparerResult CompareObjects(object x, object y, Tolerance tolerance);
Exemple #6
0
 protected abstract ComparerResult CompareObjects(object x, object y, Tolerance tolerance);
Exemple #7
0
 protected override ComparerResult CompareObjects(object x, object y, Tolerance tolerance)
 {
     throw new NotImplementedException("You cannot compare with a text comparer and a tolerance.");
 }
Exemple #8
0
 protected override ComparerResult CompareObjects(object x, object y, Tolerance tolerance)
 {
     throw new NotImplementedException("You cannot compare two booleans with a tolerance");
 }
Exemple #9
0
 public ComparerResult Compare(object x, object y, ColumnType columnType, Tolerance tolerance, Rounding rounding)
 {
     //Any management
     if (x.ToString() != "(any)" && y.ToString() != "(any)")
     {
         //Null management
         if (DBNull.Value.Equals(x))
         {
             if (!DBNull.Value.Equals(y) && y.ToString() != "(null)" && y.ToString() != "(blank)")
             {
                 return(new ComparerResult("(null)"));
             }
         }
         else if (DBNull.Value.Equals(y))
         {
             if (!DBNull.Value.Equals(x) && x.ToString() != "(null)" && x.ToString() != "(blank)")
             {
                 return(new ComparerResult(x.ToString()));
             }
         }
         //(value) management
         else if (x.ToString() == "(value)" || y.ToString() == "(value)")
         {
             if (DBNull.Value.Equals(x) || DBNull.Value.Equals(y))
             {
                 return(new ComparerResult(DBNull.Value.Equals(y) ? "(null)" : x.ToString()));
             }
         }
         //Not Null management
         else
         {
             //Numeric
             if (columnType == ColumnType.Numeric)
             {
                 //Convert to decimal
                 if (rounding != null)
                 {
                     return(numericComparer.Compare(x, y, rounding));
                 }
                 else
                 {
                     return(numericComparer.Compare(x, y, tolerance));
                 }
             }
             //Date and Time
             else if (columnType == ColumnType.DateTime)
             {
                 //Convert to dateTime
                 if (rounding != null)
                 {
                     return(dateTimeComparer.Compare(x, y, rounding));
                 }
                 else if (tolerance != null && tolerance != DateTimeTolerance.None)
                 {
                     return(dateTimeComparer.Compare(x, y, tolerance));
                 }
                 else
                 {
                     return(dateTimeComparer.Compare(x, y));
                 }
             }
             //Boolean
             else if (columnType == ColumnType.Boolean)
             {
                 //Convert to bool
                 return(booleanComparer.Compare(x, y));
             }
             //Text
             else
             {
                 if (tolerance == null || tolerance == TextSingleMethodTolerance.None)
                 {
                     return(textComparer.Compare(x, y));
                 }
                 else
                 {
                     return(textComparer.Compare(x, y, tolerance));
                 }
             }
         }
     }
     return(ComparerResult.Equality);
 }