public RemoveActivation Add <T>(Activation <T> activation)
        {
            BetaMemory <T> joinNode = GetJoinNode <T>();

            joinNode.AddActivation(activation);

            return(() => { joinNode.RemoveActivation(activation); });
        }
Example #2
0
 public IBetaMemory GetNodeMemory(IBetaMemoryNode node)
 {
     if (!_betaMap.TryGetValue(node, out var memory))
     {
         memory         = new BetaMemory();
         _betaMap[node] = memory;
     }
     return(memory);
 }
Example #3
0
		public void FirstTestName()
		{
			var junction = new JoinNode<Customer>(_constantNode);
			junction.AddSuccessor(_actionNode);

			var memoryA = new BetaMemory<Customer>(junction);

			memoryA.Activate(_context);

			_agenda.Execute();

			_context.VerifyAllExpectations();
		}
Example #4
0
        public void FirstTestName()
        {
            var junction = new JoinNode<Customer>(_constantNode);
            junction.AddSuccessor(_actionNode);

            var memoryA = new BetaMemory<Customer>(junction);

            memoryA.Activate(_context);

            _session.Run();

            _primaryCalled.IsCompleted.ShouldBeTrue();
        }
Example #5
0
        public void FirstTestName()
        {
            var junction = new JoinNode <Customer>(_constantNode);

            junction.AddSuccessor(_actionNode);

            var memoryA = new BetaMemory <Customer>(junction);

            memoryA.Activate(_context);

            _agenda.Execute();

            _context.VerifyAllExpectations();
        }
Example #6
0
        public void FirstTestName()
        {
            var junction = new JoinNode <Customer>(_constantNode);

            junction.AddSuccessor(_actionNode);

            var memoryA = new BetaMemory <Customer>(junction);

            memoryA.Activate(_context);

            _session.Run();

            _primaryCalled.IsCompleted.ShouldBeTrue();
        }
Example #7
0
 /// <summary>
 /// Called when [beta memory] is visited.
 /// </summary>
 /// <param name="beta">The beta.</param>
 public override void OnBetaMemory(BetaMemory beta)
 {
     _sb.Append(_indentString).AppendLine(string.Format("Beta: {0}", beta));
     _sb.Append(_indentString).AppendLine("  |");
     _sb.Append(_indentString).AppendLine("  |   ====== MATCHES ======");
     foreach (Token item in beta.Items)
     {
         item.Accept(this);
     }
     _sb.Append(_indentString).AppendLine("  |");
     _sb.Append(_indentString).AppendLine("  V");
     foreach (ReteNode child in beta.Children)
     {
         child.Accept(this);
     }
 }
Example #8
0
		public void Pulling_an_element_through_two_memories_should_merge_properly()
		{
			var junction = new JoinNode<Customer>(_constantNode);
			junction.AddSuccessor(_actionNode);

			var memoryB = new BetaMemory<Customer>(junction);

			var joinJunction = new JoinNode<Customer>(memoryB);

			var memoryA = new BetaMemory<Customer>(joinJunction);

			memoryA.Activate(_context);
			memoryB.Activate(_context);

			_agenda.Execute();

			_context.VerifyAllExpectations();
		}
Example #9
0
        public void Pulling_an_element_through_two_memories_should_merge_properly()
        {
            var junction = new JoinNode <Customer>(_constantNode);

            junction.AddSuccessor(_actionNode);

            var memoryB = new BetaMemory <Customer>(junction);

            var joinJunction = new JoinNode <Customer>(memoryB);

            var memoryA = new BetaMemory <Customer>(joinJunction);

            memoryA.Activate(_context);
            memoryB.Activate(_context);

            _agenda.Execute();

            _context.VerifyAllExpectations();
        }
Example #10
0
        public JoinNode(RightActivation <T> rightActivation)
        {
            _rightActivation = rightActivation;

            _betaMemory = new BetaMemory <T>();
        }
 /// <summary>
 /// Called when [beta memory] is visited.
 /// </summary>
 /// <param name="beta">The beta.</param>
 public virtual void OnBetaMemory(BetaMemory beta)
 {
 }
 /// <summary>
 /// Called when [beta memory] is visited.
 /// </summary>
 /// <param name="beta">The beta.</param>
 public override void OnBetaMemory(BetaMemory beta)
 {
     _sb.Append(_indentString).AppendLine(string.Format("Beta: {0}", beta));
     _sb.Append(_indentString).AppendLine("  |");
     _sb.Append(_indentString).AppendLine("  |   ====== MATCHES ======");
     foreach (Token item in beta.Items)
     {
         item.Accept(this);
     }
     _sb.Append(_indentString).AppendLine("  |");
     _sb.Append(_indentString).AppendLine("  V");
     foreach (ReteNode child in beta.Children)
     {
         child.Accept(this);
     }
 }
Example #13
0
 /// <summary>
 /// Called when [beta memory] is visited.
 /// </summary>
 /// <param name="beta">The beta.</param>
 public virtual void OnBetaMemory(BetaMemory beta)
 {
 }