コード例 #1
0
ファイル: DateTimeComparer.cs プロジェクト: zyh329/nbi
        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);
        }
コード例 #2
0
 private string GetToleranceText(Tolerance tolerance)
 {
     var toleranceText = string.Empty;
     if (tolerance != null)
         toleranceText += string.Format(" (+/- {0}) ", tolerance.ValueString);
     return toleranceText;
 }
コード例 #3
0
ファイル: BaseComparer.cs プロジェクト: Waltervondehans/NBi
        public ComparerResult Compare(object x, object y, Tolerance tolerance)
        {
            var eq = CompareBasic(x, y);
            if (eq != null)
                return eq;

            return CompareObjects(x, y, tolerance);
        }
コード例 #4
0
        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;
        }
コード例 #5
0
ファイル: BaseComparer.cs プロジェクト: Waltervondehans/NBi
 protected abstract ComparerResult CompareObjects(object x, object y, Tolerance tolerance);
コード例 #6
0
 protected abstract ComparerResult CompareObjects(object x, object y, Tolerance tolerance);
コード例 #7
0
ファイル: TextComparer.cs プロジェクト: gkkarthick2k/NBi
 protected override ComparerResult CompareObjects(object x, object y, Tolerance tolerance)
 {
     throw new NotImplementedException("You cannot compare with a text comparer and a tolerance.");
 }
コード例 #8
0
ファイル: BooleanComparer.cs プロジェクト: zyh329/nbi
 protected override ComparerResult CompareObjects(object x, object y, Tolerance tolerance)
 {
     throw new NotImplementedException("You cannot compare two booleans with a tolerance");
 }
コード例 #9
0
ファイル: CellComparer.cs プロジェクト: WimDeRons/NBi
 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);
 }