public async Task Should_add_conditions_to_the_engine() { IRule rule = new MyRule(); var authority = Authority.Factory.CreateAuthority(cfg => { cfg.SetLoggerFactory(ContextSetup.LoggerFactory); cfg.AddRule(rule); }); var visitor = new GraphRuntimeVisitor(); var graphContext = new GraphContext(); visitor.Visit(graphContext, authority); graphContext.Dump(Console.Out); var session = await authority.CreateSession(); FactHandle <MemberName> memberName = await session.Insert(new MemberName() { First = "Brandon", MemberId = 27 }); FactHandle <MemberAddress> memberAddress = await session.Insert(new MemberAddress() { MemberId = 27, PostalCode = "90210", }); }
async Task <FactHandle <T> > ISession.Insert <T>(T fact) { FactHandle <T> factHandle = _factIndex.Add(fact); var activationContext = new SessionFactContext <T>(this, factHandle.Fact); await _network.Insert(activationContext).ConfigureAwait(false); return(factHandle); }
public void TestTroubleTicketwithDSL() { System.IO.Stream source = Assembly.GetAssembly(this.GetType()).GetManifestResourceStream("org.drools.dotnet.examples.rules.TroubleTicketWithDSL.drl"); System.IO.Stream dsl = Assembly.GetAssembly(this.GetType()).GetManifestResourceStream("org.drools.dotnet.examples.rules.ticketing.dsl"); PackageBuilder builder = new PackageBuilder(); builder.AddPackageFromDrl(source, dsl); RuleBase ruleBase = RuleBaseFactory.NewRuleBase(); ruleBase.AddPackage(builder.GetPackage()); WorkingMemory workingMemory = ruleBase.NewWorkingMemory(); Customer a = new Customer("A", "Gold"); Customer b = new Customer("B", "Platinum"); Customer c = new Customer("C", "Silver"); Customer d = new Customer("D", "Silver"); Ticket t1 = new Ticket(a); Ticket t2 = new Ticket(b); Ticket t3 = new Ticket(c); Ticket t4 = new Ticket(d); FactHandle fa = workingMemory.assertObject(a); FactHandle fb = workingMemory.assertObject(b); FactHandle fc = workingMemory.assertObject(c); FactHandle fd = workingMemory.assertObject(d); FactHandle ft1 = workingMemory.assertObject(t1); FactHandle ft2 = workingMemory.assertObject(t2); FactHandle ft3 = workingMemory.assertObject(t3); FactHandle ft4 = workingMemory.assertObject(t4); workingMemory.fireAllRules(); t3.Status = "Done"; workingMemory.modifyObject(ft3, t3); try { System.Console.Error.WriteLine("[[ Sleeping 5 seconds ]]"); System.Threading.Thread.Sleep(new System.TimeSpan((System.Int64) 10000 * 5000)); } catch (System.Threading.ThreadInterruptedException e) { //SupportClass.WriteStackTrace(e, Console.Error); } workingMemory.fireAllRules(); //logger.writeToDisk(); }
public void TestBLoadPkg() { //AppDomain.CurrentDomain.Load("tempAssembly.dll"); FileStream stream = new FileStream("TroubleticketRuleBase.rlb", FileMode.Open); RuleBase ruleBase = RuleBaseFactory.NewRuleBase(); ruleBase.Load(stream); WorkingMemory workingMemory = ruleBase.NewWorkingMemory(); Customer a = new Customer("A", "Gold"); Customer b = new Customer("B", "Platinum"); Customer c = new Customer("C", "Silver"); Customer d = new Customer("D", "Silver"); Ticket t1 = new Ticket(a); Ticket t2 = new Ticket(b); Ticket t3 = new Ticket(c); Ticket t4 = new Ticket(d); FactHandle fa = workingMemory.assertObject(a); FactHandle fb = workingMemory.assertObject(b); FactHandle fc = workingMemory.assertObject(c); FactHandle fd = workingMemory.assertObject(d); FactHandle ft1 = workingMemory.assertObject(t1); FactHandle ft2 = workingMemory.assertObject(t2); FactHandle ft3 = workingMemory.assertObject(t3); FactHandle ft4 = workingMemory.assertObject(t4); workingMemory.fireAllRules(); t3.Status = "Done"; workingMemory.modifyObject(ft3, t3); try { System.Console.Error.WriteLine("[[ Sleeping 5 seconds ]]"); System.Threading.Thread.Sleep(new System.TimeSpan((System.Int64) 10000 * 5000)); } catch (System.Threading.ThreadInterruptedException e) { //SupportClass.WriteStackTrace(e, Console.Error); } System.Console.Error.WriteLine("[[ awake ]]"); }
public void retractObject(FactHandle handle) { this._javaWorkingMemory.retractObject(handle); }
public void modifyObject(FactHandle handle, object obj) { this._javaWorkingMemory.modifyObject(handle, obj); }
public object getObject(FactHandle handle) { return this._javaWorkingMemory.getObject(handle); }
public object getObject(FactHandle handle) { return(this._javaWorkingMemory.getObject(handle)); }