NRule: understanding sample

274 views Asked by At

I haven't done much of C# for last few years and recently I was trying to use NRules for rule engine implementation.

While going through the sample

    Context context = default;
    LastSeat lastSeat = default;
    Seating seating = default;

    When()
        .Match(() => context, c => c.State == ContextState.CheckDone)
        .Match(() => lastSeat) // <=== this one
        .Match(() => seating, s => s.RightSeatId == lastSeat.SeatId);

I couldn't get how the second line in When() method .Match(() => lastSeat) works because when I see the source code of match

public interface ILeftHandSideExpression
{

    public ILeftHandSideExpression Match<TFact>(params Expression<Func<TFact, bool>>[] conditions)
    {
       //some logic here 
        return this;
    }
}

and () => lastSeat doesn't return boolean, I couldn't get my head around this.

I tried mimicking minified version of those lambda around but couldn't get much of idea.

0

There are 0 answers