Logical aggregation patterns in C #

I am writing a small search application where I have a console that is convenient for quick cache requests for health checks, etc.

i.e.

get SomeField=Blue

this will cause all objects from the cache to be mapped to this filter.

I can apply more filters

get SomeField=Blue && SomeOtherField < 5

this can get complicated if I decide to support ()

What is a good template to use here? or perhaps a component that can take a string and label it for me?

for example, I would like to break the following into a subset of filters

get ((field1=x || field1=y) && field2>x)

the only way I can do this is with a regular expression, rather than passing substrings to different routines designed to create a specific filter. (i.e.AndEquals, OrEquals, AndGraterThan, etc.)

+3
3

, . ANTLR.

+2

IronPython. # . .

+3

- Specification.

public interface ISpecification<T>
{
    bool IsSatisfiedBy(T instance);
    ISpecification<T> And(ISpecification<T> specification);
    ISpecification<T> Or(ISpecification<T> specification);
    ISpecification<T> Not(ISpecification<T> specification);
}

+1

Source: https://habr.com/ru/post/1774430/


All Articles