예제 #1
0
        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;
            }
        }
예제 #2
0
 public static int CompareKey(IInvoker accesor, object x, object key, IComparer comparer)
 {
     return(ListHelper.Compare(accesor.GetValue(x), key, comparer, false));
 }
예제 #3
0
 public void Sort(IComparer <T> comp)
 {
     ListHelper.QuickSort <T>(items, comp);
 }
예제 #4
0
 public bool CheckItem(object item, object typedValue, CompareType comparer, IComparer comparision)
 {
     return(ListHelper.CheckItem(GetValue(item), typedValue, comparer, comparision));
 }
예제 #5
0
 public virtual void ApplySortInternal(IComparer <T> comparer)
 {
     this.comparer = comparer;
     ListHelper.QuickSort <T>(items, this.comparer);
     //_items.Sort(comparer);
 }
예제 #6
0
 public void SortInternal()
 {
     ListHelper.QuickSort <T>(items, comparer);
 }
예제 #7
0
 public IEnumerable <T> Select(QueryParameter <T> parameter)
 {
     return(ListHelper.Select <T>(this, parameter, indexes));
 }
예제 #8
0
 IEnumerable ISelectable.Select(IQueryParameter parameter)
 {
     return(ListHelper.Select <T>(this, (QueryParameter <T>)parameter, indexes));
 }
예제 #9
0
 public IEnumerable <T> Select(Query <T> query)
 {
     return(ListHelper.Select <T>(this, query, indexes));
 }
예제 #10
0
 IEnumerable ISelectable.Select(IQuery query)
 {
     return(query is Query <T> typed
         ? Select(typed)
         : ListHelper.Select(this, query, indexes));
 }
예제 #11
0
 public override bool CheckItem(T item, object typedValue, CompareType comparer, IComparer comparision)
 {
     return(ListHelper.CheckItemN <V>(GetValue(item), typedValue, comparer, (IComparer <V?>)comparision));//
 }