public void TestASaveRuleBase() { PackageBuilder builder = new PackageBuilder(); System.IO.Stream stream = Assembly.GetAssembly(this.GetType()).GetManifestResourceStream("org.drools.dotnet.examples.rules.precompiled.HelloWorld.drl"); builder.AddPackageFromDrl("HelloWorld.drl", stream); Package pkg = builder.GetPackage(); RuleBase ruleBase = RuleBaseFactory.NewRuleBase(); ruleBase.AddPackage(pkg); FileStream fstream = new FileStream("HelloworldRuleBase.rlb", FileMode.Create); ruleBase.Save(fstream); fstream.Close(); }
public void TestASavePkg() { System.IO.Stream stream = Assembly.GetAssembly(this.GetType()).GetManifestResourceStream("org.drools.dotnet.examples.rules.TroubleTicket.drl"); PackageBuilder builder = new PackageBuilder(); builder.AddPackageFromDrl(stream); Package pkg = builder.GetPackage(); RuleBase ruleBase = RuleBaseFactory.NewRuleBase(); ruleBase.AddPackage(pkg); FileStream fstream = new FileStream("TroubleticketRuleBase.rlb", FileMode.Create); ruleBase.Save(fstream); fstream.Close(); stream.Close(); }
private RuleBase readRule(System.String file, string fileName) { System.IO.Stream stream = Assembly.GetAssembly(this.GetType()).GetManifestResourceStream("org.drools.dotnet.examples.rules.benchmark." + file); PackageBuilder builder = new PackageBuilder(); builder.AddPackageFromDrl(stream); Package pkg = builder.GetPackage(); RuleBase ruleBase = RuleBaseFactory.NewRuleBase(); ruleBase.AddPackage(pkg); FileStream fstream = new FileStream(fileName, FileMode.Create); ruleBase.Save(fstream); fstream.Close(); return(ruleBase); }
public void TestBLoadAndChangeSavedState() { FileStream fstream = new FileStream("StateDynamic.rlb", FileMode.Open); RuleBase ruleBase = RuleBaseFactory.NewRuleBase(); ruleBase.Load(fstream); fstream.Close(); WorkingMemory workingMemory = ruleBase.NewWorkingMemory(); State a = new State("A"); State b = new State("B"); State c = new State("C"); State d = new State("D"); State e = new State("E"); // By setting dynamic to TRUE, Drools will use JavaBean // PropertyChangeListeners so you don't have to call modifyObject(). //UPGRADE_NOTE: Final was removed from the declaration of 'dynamic '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'" bool dynamic = true; workingMemory.assertObject(a, dynamic); workingMemory.assertObject(b, dynamic); workingMemory.assertObject(c, dynamic); workingMemory.assertObject(d, dynamic); workingMemory.assertObject(e, dynamic); workingMemory.fireAllRules(); Stream stream = Assembly.GetAssembly(this.GetType()).GetManifestResourceStream("org.drools.dotnet.examples.rules.StateExampleDynamicRule.drl"); PackageBuilder builder = new PackageBuilder(); builder.AddPackageFromDrl(stream); Package pkg = builder.GetPackage(); ruleBase.AddPackage(pkg); fstream = new FileStream("StateDynamic.rlb", FileMode.Create); ruleBase.Save(fstream); stream.Close(); fstream.Close(); }