internal int Compare(ObjectCommandPropertyValue first, ObjectCommandPropertyValue second) { if (first.IsExistingProperty && second.IsExistingProperty) { return(Compare(first.PropertyValue, second.PropertyValue)); } // if first.IsExistingProperty, !second.IsExistingProperty; otherwise the // first branch if would return. Regardless of key orders non existing property // will be considered greater than others if (first.IsExistingProperty) { return(-1); } // vice versa for the previous branch if (second.IsExistingProperty) { return(1); } // both are nonexisting return(0); }
public int Compare(OrderByPropertyEntry firstEntry, OrderByPropertyEntry secondEntry) { // we have to take into consideration that some vectors // might be shorter than others int order = 0; for (int k = 0; k < _propertyComparers.Length; k++) { ObjectCommandPropertyValue firstValue = (k < firstEntry.orderValues.Count) ? firstEntry.orderValues[k] : ObjectCommandPropertyValue.NonExistingProperty; ObjectCommandPropertyValue secondValue = (k < secondEntry.orderValues.Count) ? secondEntry.orderValues[k] : ObjectCommandPropertyValue.NonExistingProperty; order = _propertyComparers[k].Compare(firstValue, secondValue); if (order != 0) { return(order); } } return(order); }