예제 #1
0
        public void RegisterFilter(FilterTypes type, ThingItemFilter filter)
        {
            ThingItemFilterCategory result = _filters.FirstOrDefault(f => f.FilterType == type);

            if (result == null)
            {
                var category = new ThingItemFilterCategory {
                    FilterType = type
                };
                category.Filters.Add(filter);
                filter.Category = category;

                _filters.Add(category);

                return;
            }

            ThingItemFilter storedFilter = result.Filters.FirstOrDefault(f => f.Id.Equals(filter.Id));

            if (storedFilter != null)
            {
                storedFilter.Active = true;

                return;
            }

            filter.Category = result;
            result.Filters.Add(filter);
        }
예제 #2
0
        public void UnregisterFilter(FilterTypes type, string filterId)
        {
            ThingItemFilterCategory result = _filters.FirstOrDefault(f => f.FilterType == type);
            ThingItemFilter         filter = result?.Filters.FirstOrDefault(f => f.Id.Equals(filterId));

            if (filter == null)
            {
                return;
            }

            filter.Active = false;
        }