public IEnumerable <T> Scan(CompareType comparer, object paramValue, object typedValue) { if (!CheckParameter(typedValue, comparer)) { yield break; } var index = Dictionary; switch (comparer.Type) { case CompareTypes.Equal: { var key = CheckNull(typedValue); if (comparer.Not) { foreach (var entry in index) { if (!entry.Key.Equals(key)) { foreach (var item in entry.Value) { yield return(item); } } } } else { if (index.TryGetValue(key, out var value) && value != null) { foreach (var item in value) { yield return(item); } } } } break; case CompareTypes.Greater: { var key = CheckNull(typedValue); foreach (var entry in index) { if (((IComparable)entry.Key).CompareTo(key) > 0) { foreach (var item in entry.Value) { yield return(item); } } } } break; case CompareTypes.GreaterOrEqual: { var key = CheckNull(typedValue); foreach (var entry in index) { if (((IComparable)entry.Key).CompareTo(key) >= 0) { foreach (var item in entry.Value) { yield return(item); } } } } break; case CompareTypes.Less: { var key = CheckNull(typedValue); foreach (var entry in index) { if (((IComparable)entry.Key).CompareTo(key) < 0) { foreach (var item in entry.Value) { yield return(item); } } } } break; case CompareTypes.LessOrEqual: { var key = CheckNull(typedValue); foreach (var entry in index) { if (((IComparable)entry.Key).CompareTo(key) <= 0) { foreach (var item in entry.Value) { yield return(item); } } } } break; case CompareTypes.Like: { var key = CheckNull(typedValue); var stringkey = key.ToString().Trim(new char[] { '%' }); foreach (var entry in index) { if (!entry.Key.Equals(entry) && (entry.Key.ToString()).IndexOf(stringkey, StringComparison.OrdinalIgnoreCase) != -1) { foreach (var item in entry.Value) { yield return(item); } } } } break; case CompareTypes.Is: if (comparer.Not) { foreach (var entry in index) { if (!entry.Key.Equals(NullKey)) { foreach (var item in entry.Value) { yield return(item); } } } } else { if (index.TryGetValue(NullKey, out var value)) { foreach (var item in value) { yield return(item); } } } break; case CompareTypes.In: var list = paramValue.ToEnumerable(); if (comparer.Not) { foreach (var entry in index) { if (!ListHelper.Contains(list, entry.Key)) { foreach (var item in entry.Value) { yield return(item); } } } } else { foreach (var inItem in list) { if (index.TryGetValue(CheckNull(inItem), out var value)) { foreach (T item in value) { yield return(item); } } } } break; } }
public static int CompareKey(IInvoker accesor, object x, object key, IComparer comparer) { return(ListHelper.Compare(accesor.GetValue(x), key, comparer, false)); }
public void Sort(IComparer <T> comp) { ListHelper.QuickSort <T>(items, comp); }
public bool CheckItem(object item, object typedValue, CompareType comparer, IComparer comparision) { return(ListHelper.CheckItem(GetValue(item), typedValue, comparer, comparision)); }
public virtual void ApplySortInternal(IComparer <T> comparer) { this.comparer = comparer; ListHelper.QuickSort <T>(items, this.comparer); //_items.Sort(comparer); }
public void SortInternal() { ListHelper.QuickSort <T>(items, comparer); }
public IEnumerable <T> Select(QueryParameter <T> parameter) { return(ListHelper.Select <T>(this, parameter, indexes)); }
IEnumerable ISelectable.Select(IQueryParameter parameter) { return(ListHelper.Select <T>(this, (QueryParameter <T>)parameter, indexes)); }
public IEnumerable <T> Select(Query <T> query) { return(ListHelper.Select <T>(this, query, indexes)); }
IEnumerable ISelectable.Select(IQuery query) { return(query is Query <T> typed ? Select(typed) : ListHelper.Select(this, query, indexes)); }
public override bool CheckItem(T item, object typedValue, CompareType comparer, IComparer comparision) { return(ListHelper.CheckItemN <V>(GetValue(item), typedValue, comparer, (IComparer <V?>)comparision));// }