コード例 #1
0
        private void ChangeFilterIsEnabledIfNotOverrided(List <DataFilterConfiguration> filterOverrides, string filterName, bool isEnable)
        {
            if (filterOverrides.Any(f => f.FilterName == filterName))
            {
                return;
            }

            var index = filters.FindIndex(f => f.FilterName == filterName);

            if (index < 0)
            {
                return;
            }

            if (filters[index].IsEnable == isEnable)
            {
                return;
            }

            filters[index] = new DataFilterConfiguration(filterName, isEnable);
        }
コード例 #2
0
        public IDisposable SetFilterParameter(string filterName, string parameterName, object value)
        {
            var    filterIndex = GetFilterIndex(filterName);
            var    newFilter   = new DataFilterConfiguration(filters[filterIndex]);
            object oldValue    = null;
            var    hasOldValue = newFilter.FilterParameters.ContainsKey(parameterName);

            if (hasOldValue)
            {
                oldValue = newFilter.FilterParameters[parameterName];
            }

            newFilter.FilterParameters[parameterName] = value;
            filters[filterIndex] = newFilter;
            ApplyFilterParameterValue(filterName, parameterName, value);

            return(new DisposeAction(() =>
            {
                if (hasOldValue)
                {
                    SetFilterParameter(filterName, parameterName, value);
                }
            }));
        }