Exemplo n.º 1
0
 private bool CompareValue(Comparison comparison, Object operand, Object value)
 {
     if (operand == null)
     {
         return (comparison.ContainedWithin(Comparison.Null, Comparison.NullOrEmpty) ||
                 ((comparison == Comparison.EqualTo) &&
                  (value == null)));
     }
     if (!comparison.IsOperandOnlyComparison())
     {
         if (value == null)
         {
             return false;
         }
         GetComparisonValues(ref operand, ref value);
     }
     var stringOperand = operand as string;
     if (stringOperand != null)
     {
         var typedValue = Convert.ToString(value);
         return CompareString(comparison, stringOperand, typedValue);
     }
     var comparableOperand = operand as IComparable;
     if (comparableOperand != null)
     {
         var type = comparableOperand.GetType();
         var typedValue = (IComparable)Convert.ChangeType(value, type);
         return CompareComparable(comparison, comparableOperand, typedValue);
     }
     return comparison == Comparison.EqualTo && Equals(operand, value);
 }