private string GetComparedText() { if (Compared is DBNull) { return("(null)"); } if (Compared is string && ((string)Compared).Length == 0) { return("(empty)"); } return(Compared.ToString()); }
public static bool HasBeenCompared(object obj, object to) { Assert.AreNotSame(obj, to); // only carry on to compare facets if first time if (Compared.ContainsKey(obj)) { Assert.AreSame(Compared[obj], to); return(true); } Compared[obj] = to; return(false); }
public static bool HasBeenCompared(ISpecification spec, object to) { Assert.AreNotSame(spec, to); // only carry on to compare facets if first time if (Compared.ContainsKey(spec)) { Assert.AreSame(Compared[spec], to); return(true); } Compared[spec] = to; return(false); }
public override bool Validate() { int value = Compared.GetValue(); foreach (int flag in flags) value = value & ~flag; if (value > 0) { List<int> unsupported_flags = new List<int>(); string bits = Convert.ToString(value, 2); for (int i = 0; i < bits.Length; ++i) { if (bits[i] == '1') { unsupported_flags.Add((int)Math.Pow(2, (bits.Length - i - 1))); } } Description = Compared.Name + " contains unsupported flags: " + String.Join(", ", unsupported_flags); return false; } return true; }
public override bool Validate() { switch (compareType) { case CompareType.EQUALS: return Compared.GetValue() == CompareTo.GetValue(); case CompareType.NOT_EQUALS: return Compared.GetValue() != CompareTo.GetValue(); case CompareType.LOWER_THAN: return Compared.GetValue() < CompareTo.GetValue(); case CompareType.GREATER_THAN: return Compared.GetValue() > CompareTo.GetValue(); case CompareType.LOWER_OR_EQUALS: return Compared.GetValue() <= CompareTo.GetValue(); case CompareType.GREATER_OR_EQUALS: return Compared.GetValue() >= CompareTo.GetValue(); case CompareType.BETWEEN: return Compared.GetValue() >= CompareTo.GetValue() && Compared.GetValue() <= max; } return false; }
public void ResetRules() { rankComaparison = TTRule.Compare; afterCompareCallback = null; }
/// <summary> /// Compare items[<paramref name="indA"/>] > item[<paramref name="indB"/>] /// </summary> protected bool Compare(int indA, int indB) { Compared?.Invoke(indA, indB); ComprasionsCount++; return(collection[indA] > collection[indB]); }
public bool IsSmaller(int pos1, int pos2) { Compared?.Invoke(pos1, pos2); return(Get(pos1) < Get(pos2)); }
public bool IsBigger(int pos1, int pos2) { Compared?.Invoke(pos1, pos2); return(Get(pos1) > Get(pos2)); }
public bool IsEqual(int pos1, int pos2) { Compared?.Invoke(pos1, pos2); return(Get(pos1) == Get(pos2)); }