private static bool EvaluateAttachmentRestriction(Restriction.AttachmentRestriction restriction, IRuleEvaluationContext context) { context.TraceFunction("AttachmentRestriction"); context.NestedLevel++; bool flag = false; foreach (AttachmentHandle handle in context.Message.AttachmentCollection) { using (Attachment attachment = context.Message.AttachmentCollection.Open(handle)) { context.TraceFunction <string>("Attachment {0}", attachment.DisplayName); using (IRuleEvaluationContext attachmentContext = context.GetAttachmentContext(attachment)) { if (RestrictionEvaluator.Evaluate(restriction.Restriction, attachmentContext)) { flag = true; break; } } } } context.NestedLevel--; context.TraceFunction <bool>("AttachmentRestriction evaluates to {0}", flag); return(flag); }
private static bool EvaluateNotRestriction(Restriction.NotRestriction restriction, IRuleEvaluationContext context) { context.NestedLevel++; bool flag = !RestrictionEvaluator.Evaluate(restriction.Restriction, context); context.NestedLevel--; context.TraceFunction <bool>("NotRestriction evaluated to {0}", flag); return(flag); }
private static bool EvaluateOrRestriction(Restriction.OrRestriction restriction, IRuleEvaluationContext context) { context.NestedLevel++; bool flag = false; foreach (Restriction restriction2 in restriction.Restrictions) { if (RestrictionEvaluator.Evaluate(restriction2, context)) { flag = true; break; } } context.NestedLevel--; context.TraceFunction <bool>("OrRestriction evaluated to {0}", flag); return(flag); }
private static bool EvaluateRecipientRestriction(Restriction.RecipientRestriction restriction, IRuleEvaluationContext context) { context.TraceFunction("RecipientRestriction"); context.NestedLevel++; bool flag = false; foreach (Recipient recipient in context.Message.Recipients) { using (IRuleEvaluationContext recipientContext = context.GetRecipientContext(recipient)) { context.TraceFunction <string>("Recipient {0}", recipient.Participant.DisplayName); if (RestrictionEvaluator.Evaluate(restriction.Restriction, recipientContext)) { flag = true; break; } } } context.NestedLevel--; context.TraceFunction <bool>("RecipientRestriction evaluates to {0}", flag); return(flag); }
private bool EvaluateRule(Rule rule, FolderEvaluationResult result) { if (rule == null) { throw new ArgumentNullException("rule"); } if (result == null) { throw new ArgumentNullException("result"); } if (rule.Actions == null) { throw new ArgumentException("Rule.Actions must not be null."); } this.context.CurrentRule = rule; this.context.NestedLevel = 0; this.context.TraceDebug <string>("Evaluate rule {0}", rule.Name); int i = 0; bool result2; try { RuleUtil.FaultInjection((FaultInjectionLid)3102092605U); if (!RestrictionEvaluator.Evaluate(rule.Condition, this.context)) { result2 = false; } else { this.context.TraceDebug <string>("Rule {0} evaluated to true", rule.Name); if (this.context.HasRuleFiredBefore(rule)) { this.context.TraceDebug <string>("Rule history loop detected on rule {0}", rule.Name); result2 = false; } else { while (i < rule.Actions.Length) { RuleAction ruleAction = rule.Actions[i]; if (ruleAction == null) { this.context.TraceDebug <string, int>("For rule \"{0}\", action at index {1} is null.", rule.Name, i); } else { this.CreateWorkItemForAction(result, ruleAction, i++); if (!result.ShouldContinue) { this.context.TraceDebug <Type>("Stop evaluation process after action {0}", ruleAction.GetType()); break; } } } result2 = true; } } } catch (InvalidRuleException exception) { this.context.DisableAndMarkRuleInError(rule, rule.Actions[i].ActionType, i, DeferredError.RuleError.Parsing); this.context.RecordError(exception, ServerStrings.FolderRuleStageEvaluation); result2 = false; } return(result2); }