Ejemplo n.º 1
0
 private void NewFactHandler(NewFactEventArgs nfea)
 {
     if (nfea.Fact.Type == "Fraudulent Customer")
     {
         ((Customer)nfea.Fact.GetPredicateValue(0)).Fraudulent = true;
     }
 }
Ejemplo n.º 2
0
 private void NewFactHandler(NewFactEventArgs nfea)
 {
     if (nfea.Fact.Type == "WeightError")
     {
         ((PhysicalObject)nfea.Fact.GetPredicateValue(0)).HasErrors = true;
     }
 }
Ejemplo n.º 3
0
        private void ModifyFactHandlerWithContext(NewFactEventArgs nfea)
        {
            modifyFactEventCount++;

            Assert.AreEqual("Modifying Implication", nfea.Context.Implication.Label);
            Assert.AreEqual("((toModify{whatever}))", Misc.IListToString(nfea.Context.Facts));
        }
Ejemplo n.º 4
0
        private void RetractFactHandlerWithContext(NewFactEventArgs nfea)
        {
            deleteFactEventCount++;

            Assert.AreEqual("Retracting Implication", nfea.Context.Implication.Label);
            Assert.AreEqual("((trigger{whatever}))", Misc.IListToString(nfea.Context.Facts));
        }
Ejemplo n.º 5
0
 private void HandleDelFactEvent(NewFactEventArgs nfea)
 {
     if (menuItemShowDeletions.Checked)
     {
         ConsoleOut("- " + nfea.Fact);
     }
 }
Ejemplo n.º 6
0
 private void ModifyFactHandler(NewFactEventArgs nfea)
 {
     NewWorkingBRE();
     working_bre.RuleContext.SetObject(MODIFIEDFACT_ID, nfea.Fact);
     working_bre.RuleContext.SetObject(MODIFIEDOTHERFACT_ID, nfea.OtherFact);
     working_bre.Process(ON_MODIFY_FACT);
 }
Ejemplo n.º 7
0
 protected void HandleModifiedFactEvent(NewFactEventArgs nfea)
 {
     if (logThreshold == LogEventImpl.DEBUG)
     {
         Console.WriteLine("* Modified : {0}->{1}", nfea.Fact, nfea.OtherFact);
     }
     modified++;
 }
Ejemplo n.º 8
0
 protected void HandleDeletedFactEvent(NewFactEventArgs nfea)
 {
     if (logThreshold == LogEventImpl.DEBUG)
     {
         Console.WriteLine("- Deleted : {0}", nfea.Fact);
     }
     deleted++;
 }
Ejemplo n.º 9
0
 private void HandleModFactEvent(NewFactEventArgs nfea)
 {
     if (menuItemShowModifications.Checked)
     {
         ConsoleOut("< " + nfea.Fact);
         ConsoleOut("> " + nfea.OtherFact);
     }
 }
Ejemplo n.º 10
0
 protected void HandleModifiedFactEvent(NewFactEventArgs nfea)
 {
     if (Logger.IsInferenceEngineVerbose)
     {
         Logger.InferenceEngineSource.TraceEvent(TraceEventType.Verbose, 0, "* Modified: " + nfea.Fact + " -> " + nfea.OtherFact);
     }
     modified++;
 }
Ejemplo n.º 11
0
 protected void HandleDeletedFactEvent(NewFactEventArgs nfea)
 {
     if (Logger.IsInferenceEngineVerbose)
     {
         Logger.InferenceEngineSource.TraceEvent(TraceEventType.Verbose, 0, "- Deleted: " + nfea.Fact);
     }
     deleted++;
 }
Ejemplo n.º 12
0
        protected void HandleOrderedNewFact(NewFactEventArgs nfea)
        {
            if ((deductionsToCheck != null) && (deductionsToCheck[deductionChecker] != nfea.Fact.ToString(false)))
            {
                wrongDeduction = true;
                Console.Error.WriteLine("* Wrongly Deducted: {0} @ {1}, Expected: {2}", nfea.Fact, deductionChecker, deductionsToCheck[deductionChecker]);
            }

            deductionChecker++;
        }
Ejemplo n.º 13
0
        protected void HandleExpectedNewFact(NewFactEventArgs nfea)
        {
            if ((deductionsToCheck != null) && (Array.IndexOf(deductionsToCheck, nfea.Fact.ToString(false)) < 0))
            {
                wrongDeduction = true;
                Console.Error.WriteLine("* Wrongly Deducted: {0} @ {1} !!! !!!", nfea.Fact, deductionChecker);
            }

            deductionChecker++;
        }
Ejemplo n.º 14
0
        private void AssertFactHandlerWithContext(NewFactEventArgs nfea)
        {
            newFactEventCount++;

            string label = nfea.Context.Implication.Label;

            if (label == "Asserting Implication")
            {
                Assert.AreEqual("((trigger{whatever}))", Misc.IListToString(nfea.Context.Facts));
            }
            else if (label == "Counting Implication")
            {
                Assert.AreEqual("((toCount{a}),(toCount{b}),(toCount{c}))", Misc.IListToString(nfea.Context.Facts));
            }
            else
            {
                Assert.Fail("Unexpected implication label: " + label);
            }
        }
Ejemplo n.º 15
0
 protected void ShowAllNewFacts(NewFactEventArgs nfea)
 {
     deducted++;
 }
Ejemplo n.º 16
0
 private void HandleNewFactEvent(NewFactEventArgs nfea)
 {
     Console.WriteLine("* Deducted: {0}", nfea.Fact);
 }
Ejemplo n.º 17
0
 private void DeleteFactHandler(NewFactEventArgs nfea)
 {
     NewWorkingBRE();
     working_bre.RuleContext.SetObject(DELETEDFACT_ID, nfea.Fact);
     working_bre.Process(ON_DELETE_FACT);
 }
Ejemplo n.º 18
0
 protected void ShowAllNewFacts(NewFactEventArgs nfea)
 {
     deducted++;
     Console.WriteLine("NxBRE Deducted: {0}", nfea.Fact);
 }
Ejemplo n.º 19
0
 private void HandleModFactEvent(NewFactEventArgs nfea)
 {
     if (menuItemShowModifications.Checked) {
         ConsoleOut("< " + nfea.Fact);
         ConsoleOut("> " + nfea.OtherFact);
     }
 }
Ejemplo n.º 20
0
 private void HandleNewFactEvent(NewFactEventArgs nfea)
 {
     if (menuItemShowDeductions.Checked) ConsoleOut("+ " + nfea.Fact);
 }
Ejemplo n.º 21
0
 private void DeleteFactHandler(NewFactEventArgs nfea)
 {
     NewWorkingBRE();
     working_bre.RuleContext.SetObject(DELETEDFACT_ID, nfea.Fact);
     working_bre.Process(ON_DELETE_FACT);
 }
Ejemplo n.º 22
0
 private void NewFactHandler(NewFactEventArgs nfea)
 {
     NewWorkingBRE();
     working_bre.RuleContext.SetObject(NEWFACT_ID, nfea.Fact);
     working_bre.Process(ON_NEW_FACT);
 }
Ejemplo n.º 23
0
 private void ModifyFactHandler(NewFactEventArgs nfea)
 {
     NewWorkingBRE();
     working_bre.RuleContext.SetObject(MODIFIEDFACT_ID, nfea.Fact);
     working_bre.RuleContext.SetObject(MODIFIEDOTHERFACT_ID, nfea.OtherFact);
     working_bre.Process(ON_MODIFY_FACT);
 }
Ejemplo n.º 24
0
 private void NewFactHandler(NewFactEventArgs nfea)
 {
     NewWorkingBRE();
     working_bre.RuleContext.SetObject(NEWFACT_ID, nfea.Fact);
     working_bre.Process(ON_NEW_FACT);
 }
Ejemplo n.º 25
0
        private void EventHandlerWithoutContext(NewFactEventArgs nfea)
        {
            factEventCount++;

            Assert.IsNull(nfea.Context);
        }