public void Setup() { _called = null; var configurator = new RuntimeConfiguratorImpl(); var productionNode = new DelegateProductionNode <A>(16, (session, x) => _called = x); var constantNode = new ConstantNode <A>(42); var joinNode = configurator.CreateNode(id => new JoinNode <A>(id, constantNode)); var constantNode2 = new ConstantNode <A>(27); var joinNode2 = configurator.CreateNode(id => new JoinNode <A>(id, constantNode2)); joinNode2.AddActivation(productionNode); joinNode.AddActivation(joinNode2); var engine = new OdoyuleRulesEngine(configurator); AlphaNode <A> alphaNode = engine.GetAlphaNode <A>(); alphaNode.AddActivation(joinNode); using (StatefulSession session = engine.CreateSession()) { session.Add(new A()); session.Run(); } }
public void AddActivation <TParent>(OdoyuleRulesEngine rulesEngine, AlphaNode <TParent> activation) where TParent : class { AlphaNode <T> alphaNode = rulesEngine.GetAlphaNode <T>(); RunLocator(activation, alphaNode); }
RulesEngineGraph CreateRulesEngineGraph(OdoyuleRulesEngine machine) { var visitor = new GraphRulesEngineVisitor(); machine.Accept(visitor); return visitor.Graph; }
public OdoyuleRuntimeConfigurator() { _propertySelectors = new DictionaryCache <Type, PropertySelector>(); _propertySelectorFactories = new Stack <PropertySelectorFactory>(); _propertySelectorFactories.Push(new DefaultPropertySelectorFactory()); _rulesEngine = new OdoyuleRulesEngine(this); }
public static RulesEngineGraph GetGraph(this OdoyuleRulesEngine rulesEngine) { var inspector = new GraphRulesEngineVisitor(); rulesEngine.Accept(inspector); return(inspector.Graph); }
RulesEngineGraph CreateRulesEngineGraph(OdoyuleRulesEngine machine) { var visitor = new GraphRulesEngineVisitor(); machine.Accept(visitor); return(visitor.Graph); }
public void AddActivation <TParent>(OdoyuleRulesEngine rulesEngine, AlphaNode <TParent> activation) where TParent : class { AlphaNode <TParent> alphaNode = rulesEngine.GetAlphaNode <TParent>(); Type convertNodeType = typeof(ConvertNode <,>).MakeGenericType(typeof(TParent), typeof(T)); var adapter = (Activation <TParent>)Activator.CreateInstance(convertNodeType, alphaNode); activation.AddActivation(adapter); }
public void Setup() { _called = null; var productionNode = new DelegateProductionNode<A>(16, (session,x) => _called = x); var constantNode = new ConstantNode<A>(42); var joinNode = new JoinNode<A>(69, constantNode); joinNode.AddActivation(productionNode); var engine = new OdoyuleRulesEngine(new OdoyuleRuntimeConfigurator()); AlphaNode<A> alphaNode = engine.GetAlphaNode<A>(); alphaNode.AddActivation(joinNode); using (Session session = engine.CreateSession()) { session.Add(new A()); session.Run(); } }
public void Setup() { _called = null; var configurator = new OdoyuleRuntimeConfigurator(); var productionNode = new DelegateProductionNode <Tuple <A, B> >(16, (session, x) => _called = x); var constantNode = new ConstantNode <A>(42); JoinNode <A> joinNodeA = configurator.CreateNode(id => new JoinNode <A>(id, constantNode)); var constantNode2 = new ConstantNode <B>(27); JoinNode <B> joinNodeB = configurator.CreateNode(id => new JoinNode <B>(id, constantNode2)); OuterJoinNode <A, B> outerJoinNode = configurator.CreateNode(id => new OuterJoinNode <A, B>(id, joinNodeB)); outerJoinNode.AddActivation(productionNode); joinNodeA.AddActivation(outerJoinNode); var engine = new OdoyuleRulesEngine(configurator); AlphaNode <A> alphaNode = engine.GetAlphaNode <A>(); alphaNode.AddActivation(joinNodeA); AlphaNode <B> alphaNodeB = engine.GetAlphaNode <B>(); alphaNodeB.AddActivation(joinNodeB); using (Session session = engine.CreateSession()) { session.Add(new A()); session.Add(new B()); session.Run(); } }
public void Setup() { _called = null; var configurator = new OdoyuleRuntimeConfigurator(); var productionNode = new DelegateProductionNode<Tuple<A,B>>(16, (session, x) => _called = x); var constantNode = new ConstantNode<A>(42); JoinNode<A> joinNodeA = configurator.CreateNode(id => new JoinNode<A>(id, constantNode)); var constantNode2 = new ConstantNode<B>(27); JoinNode<B> joinNodeB = configurator.CreateNode(id => new JoinNode<B>(id, constantNode2)); OuterJoinNode<A, B> outerJoinNode = configurator.CreateNode(id => new OuterJoinNode<A, B>(id, joinNodeB)); outerJoinNode.AddActivation(productionNode); joinNodeA.AddActivation(outerJoinNode); var engine = new OdoyuleRulesEngine(configurator); AlphaNode<A> alphaNode = engine.GetAlphaNode<A>(); alphaNode.AddActivation(joinNodeA); AlphaNode<B> alphaNodeB = engine.GetAlphaNode<B>(); alphaNodeB.AddActivation(joinNodeB); using (Session session = engine.CreateSession()) { session.Add(new A()); session.Add(new B()); session.Run(); } }
public void Setup() { _called = null; var productionNode = new DelegateProductionNode <A>(16, (session, x) => _called = x); var constantNode = new ConstantNode <A>(42); var joinNode = new JoinNode <A>(69, constantNode); joinNode.AddActivation(productionNode); var engine = new OdoyuleRulesEngine(new OdoyuleRuntimeConfigurator()); AlphaNode <A> alphaNode = engine.GetAlphaNode <A>(); alphaNode.AddActivation(joinNode); using (Session session = engine.CreateSession()) { session.Add(new A()); session.Run(); } }
public void Setup() { _called = null; var configurator = new RuntimeConfiguratorImpl(); var productionNode = new DelegateProductionNode<A>(16, (session,x) => _called = x); var constantNode = new ConstantNode<A>(42); var joinNode = configurator.CreateNode(id => new JoinNode<A>(id, constantNode)); var constantNode2 = new ConstantNode<A>(27); var joinNode2 = configurator.CreateNode(id => new JoinNode<A>(id, constantNode2)); joinNode2.AddActivation(productionNode); joinNode.AddActivation(joinNode2); var engine = new OdoyuleRulesEngine(configurator); AlphaNode<A> alphaNode = engine.GetAlphaNode<A>(); alphaNode.AddActivation(joinNode); using (StatefulSession session = engine.CreateSession()) { session.Add(new A()); session.Run(); } }
public RuntimeConfiguratorImpl() { _rulesEngine = new OdoyuleRulesEngine(this); }