Пример #1
0
        public WhatToDoNext Not()
        {
            if (Filters.Count == 0)
            {
                throw new InvalidOperationException("'not' must be specified after a filter");
            }

            int lastIndex = Filters.Count - 1;
            TypeFilterFactory lastFilter = Filters[lastIndex];

            Filters[lastIndex] = delegate { return(new NotFilter(lastFilter())); };
            return(WhatToDoNext.GoAhead);
        }
        public TBuilder FilterWith <TFilter, TBaseRequest, TBaseEntity>()
            where TBaseEntity : class
            where TFilter : IFilter <TBaseRequest, TBaseEntity>
        {
            if (!typeof(TBaseRequest).IsAssignableFrom(typeof(TRequest)))
            {
                throw new ContravarianceException(nameof(FilterWith), typeof(TBaseRequest), typeof(TRequest));
            }

            if (!typeof(TBaseEntity).IsAssignableFrom(typeof(TEntity)))
            {
                throw new ContravarianceException(nameof(FilterWith), typeof(TBaseEntity), typeof(TEntity));
            }

            return(AddRequestFilter(TypeFilterFactory.From <TFilter, TBaseRequest, TBaseEntity>()));
        }