示例#1
0
        private bool IsInterest(ClassifierRule classifier)
        {
            /*
             * Keep all discard & archive parsing rules.
             * Else, if rule (or child rule, recursive) interest level is lower than provided (0 default), then discard
             */
            try
            {
                if (classifier.RelayTargets != null)
                {
                    int max = 0;
                    foreach (string relayTarget in classifier.RelayTargets)
                    {
                        try
                        {
                            ClassifierRule relayRule = ClassifierRules.First(thing => thing.RuleName == relayTarget);

                            if (
                                (relayRule.Triage == Triage.Black && InterestLevel > 3) ||
                                (relayRule.Triage == Triage.Red && InterestLevel > 2) ||
                                (relayRule.Triage == Triage.Yellow && InterestLevel > 1) ||
                                (relayRule.Triage == Triage.Green && InterestLevel > 0))
                            {
                                return(true);
                            }
                        }
                        catch (Exception e)
                        {
                            throw new Exception("You have a misconfigured rule trying to relay to " + relayTarget + " and no such rule exists by that name.");
                        }
                    }
                }


                bool actualThing = !(
                    (
                        classifier.MatchAction == MatchAction.Snaffle ||
                        classifier.MatchAction == MatchAction.CheckForKeys
                    ) &&
                    (
                        (classifier.Triage == Triage.Black && InterestLevel > 3) ||
                        (classifier.Triage == Triage.Red && InterestLevel > 2) ||
                        (classifier.Triage == Triage.Yellow && InterestLevel > 1) ||
                        (classifier.Triage == Triage.Green && InterestLevel > 0)
                    )
                    );
                return(actualThing);
            }
            catch (Exception e)
            {
                Console.WriteLine(classifier.RuleName);
                Console.WriteLine(e.ToString());
            }
            return(true);
        }
示例#2
0
 private bool IsInterest(ClassifierRule classifier)
 {
     /*
      * Keep all discard & archive parsing rules.
      * Else, if rule (or child rule, recursive) interest level is lower than provided (0 default), then discard
      */
     if (!String.IsNullOrEmpty(classifier.RelayTarget))
     {
         return(IsInterest(ClassifierRules.First(thing => thing.RuleName == classifier.RelayTarget)));
     }
     return(!(
                (
                    classifier.MatchAction == MatchAction.Snaffle ||
                    classifier.MatchAction == MatchAction.CheckForKeys
                ) &&
                (
                    (classifier.Triage == Triage.Red && InterestLevel > 2) ||
                    (classifier.Triage == Triage.Yellow && InterestLevel > 1) ||
                    (classifier.Triage == Triage.Green && InterestLevel > 0)
                )
                ));
 }