/// <summary>Enables this filter on the specified types.</summary>
        /// <param name="filter">The filter to enable.</param>
        /// <param name="types">A variable-length parameters list containing types to enable the filter on.</param>
        public void EnableFilter(BaseQueryFilter filter, params Type[] types)
        {
            List <QueryFilterSet> filterSets;

            // CHECK if the element type can be used in the context
            if (FilterSetByType.TryGetValue(filter.ElementType, out filterSets))
            {
                if (types != null)
                {
                    var applySets = new List <QueryFilterSet>();

                    foreach (var type in types)
                    {
                        List <QueryFilterSet> setToAdd;
                        if (FilterSetByType.TryGetValue(type, out setToAdd))
                        {
                            applySets.AddRange(setToAdd);
                        }
                    }

                    // KEEP only applicable filter set
                    filterSets = filterSets.Intersect(applySets.Distinct()).ToList();
                }

                foreach (var set in filterSets)
                {
                    set.AddOrGetFilterQueryable(Context).EnableFilter(filter);
                }
            }
        }
Beispiel #2
0
 /// <summary>Disables the filter on the associated query.</summary>
 /// <param name="filter">The filter to disable on the associated query.</param>
 public void DisableFilter(BaseQueryFilter filter)
 {
     if (Filters.Remove(filter))
     {
         UpdateInternalQuery();
     }
 }
Beispiel #3
0
 /// <summary>Enables the filter on the associated query.</summary>
 /// <param name="filter">The filter to enable on the associated query.</param>
 public void EnableFilter(BaseQueryFilter filter)
 {
     if (!Filters.Contains(filter))
     {
         Filters.Add(filter);
         UpdateInternalQuery();
     }
 }