static void Main(string[] args) { var repository = new RuleRepository(); repository.Load(x => x.From(typeof(AssignFirstSeat).Assembly)); var factory = repository.Compile(); var session = factory.CreateSession(); session.Events.FactInsertingEvent += EventProviderOnFactInsertingEvent; session.Events.FactUpdatingEvent += EventProviderOnFactUpdatingEvent; session.Events.FactRetractingEvent += EventProviderOnFactRetractingEvent; session.Events.ActivationCreatedEvent += EventProviderOnActivationCreatedEvent; session.Events.ActivationUpdatedEvent += EventProviderOnActivationUpdatedEvent; session.Events.ActivationDeletedEvent += EventProviderOnActivationDeletedEvent; session.Events.RuleFiringEvent += EventProviderOnRuleFiringEvent; session.Insert(new Guest("N1", Gender.Male, new Hobby("H1"))); session.Insert(new Guest("N2", Gender.Female, new Hobby("H1"))); session.Insert(new Guest("N2", Gender.Female, new Hobby("H3"))); session.Insert(new Guest("N3", Gender.Male, new Hobby("H3"))); session.Insert(new Guest("N4", Gender.Male, new Hobby("H1"))); session.Insert(new Guest("N4", Gender.Female, new Hobby("H2"))); session.Insert(new Guest("N4", Gender.Female, new Hobby("H3"))); session.Insert(new Guest("N5", Gender.Female, new Hobby("H2"))); session.Insert(new Guest("N5", Gender.Female, new Hobby("H1"))); session.Insert(new Count(1)); session.Insert(new LastSeat(5)); var context = new Context(); session.Insert(context); session.Fire(); }
private void CompletePath(IContext ctx, Context context, Seating seating) { seating.SetPathDone(); ctx.Update(seating); context.SetState(ContextState.CheckDone); ctx.Update(context); }
private void AssignSeat(IContext ctx, Context context, Guest guest, Count count) { var cnt = count.Value; var seating = new Seating(cnt, 0, true, 1, guest.Name, 1, guest.Name); ctx.Insert(seating); var path = new Path(cnt, 1, guest.Name); ctx.Insert(path); count.Increment(); ctx.Update(count); context.SetState(ContextState.AssignSeats); ctx.Update(context); }
private void AssignSeat(IContext ctx, Context context, Seating seating, Guest guest1, Guest guest2, Count count) { int rightSeat = seating.RightSeatId; int seatId = seating.Id; int cnt = count.Value; var newSeating = new Seating(cnt, seatId, false, rightSeat, seating.RightGuestName, rightSeat + 1, guest2.Name); ctx.Insert(newSeating); var path = new Path(cnt, rightSeat + 1, guest2.Name); ctx.Insert(path); var chosen = new Chosen(seatId, guest2.Name, guest1.Hobby); ctx.Insert(chosen); count.Increment(); ctx.Update(count); context.SetState(ContextState.MakePath); ctx.Update(context); }
private void MakeNewPath(IContext ctx, Context context, Seating seating, Path path) { var newPath = new Path(seating.Id, path.SeatId, path.GuestName); ctx.Insert(newPath); }