protected virtual int BinarySearchIndex <U> (IPropertyComparer <T, U> comparer, U value) { int min = 0; int max = List.Count - 1; int cmp = 0; while (min <= max) { int mid = (min + max) / 2; cmp = comparer.Compare(this[mid], value); if (cmp == 0) { return(mid); } else if (cmp > 0) { max = mid - 1; } else { min = mid + 1; // compensate for the rounding down } } return(~min); }
protected virtual int SearchIndex <U> (IPropertyComparer <T, U> comparer, U value) { int max = List.Count - 1; for (int i = 0; i < max; i++) { if (comparer.Compare(this[i], value) == 0) { return(i); } } return(-1); }
/// <summary> /// Compares two BusinessObjects using this field. /// </summary> /// <typeparam name="T">The Type of objects being compared. This must be a class that implements IBusinessObject</typeparam> /// <param name="bo1">The first object to compare</param> /// <param name="bo2">The object to compare the first with</param> /// <returns>a value less than 0 if bo1 is less than bo2, 0 if bo1 = bo2 and greater than 0 if b01 is greater than bo2 /// The value returned is negated if the SortDirection is Descending</returns> public int Compare <T>(T bo1, T bo2) where T : IBusinessObject { if (_comparer == null) { _classDef = bo1.ClassDef; _fullNameExcludingPrimarySource = this.FullNameExcludingPrimarySource; _comparer = _classDef.CreatePropertyComparer <IBusinessObject>(_fullNameExcludingPrimarySource); } IPropertyComparer <IBusinessObject> comparer = (IPropertyComparer <IBusinessObject>)_comparer; comparer.PropertyName = PropertyName; comparer.Source = Source != null && Source.ChildSource != null ? Source.ChildSource : null; int compareResult = comparer.Compare(bo1, bo2); if (compareResult != 0) { return(SortDirection == SortDirection.Ascending ? compareResult : -compareResult); } return(0); }
private bool HasPropertyChange(SyncSession session, IPropertyComparer comparer, PropertyMapping mapping, NameObjectCollection srcValues, SchemaObjectBase targetObj) { return(comparer.AreEqual(session, mapping, srcValues, targetObj) == false); }
public PropertyMatchProcessor( IPropertyEvaluator evaluator, IPropertyComparer comparer, ILogger?logger) : base(evaluator, comparer, logger) { }
private bool HasPropertyChange(SyncSession session, IPropertyComparer comparer, PropertyMapping mapping, NameObjectCollection srcValues, SchemaObjectBase targetObj) { return comparer.AreEqual(session, mapping, srcValues, targetObj) == false; }