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); }
internal AttachmentRestrictionData(Restriction.AttachmentRestriction r) { base.ParseRestrictions(new Restriction[] { r.Restriction }); }
internal void WriteRestriction(Restriction restriction) { if (restriction is Restriction.BitMaskRestriction) { Restriction.BitMaskRestriction bitMaskRestriction = (Restriction.BitMaskRestriction)restriction; this.WriteInt(6); this.WriteInt((int)bitMaskRestriction.Bmr); this.WriteInt((int)bitMaskRestriction.Tag); this.WriteInt(bitMaskRestriction.Mask); return; } if (restriction is Restriction.AndRestriction) { this.WriteInt(0); Restriction.AndRestriction andRestriction = (Restriction.AndRestriction)restriction; this.WriteInt(andRestriction.Restrictions.Length); foreach (Restriction restriction2 in andRestriction.Restrictions) { this.WriteRestriction(restriction2); } return; } if (restriction is Restriction.OrRestriction) { this.WriteInt(1); Restriction.OrRestriction orRestriction = (Restriction.OrRestriction)restriction; this.WriteInt(orRestriction.Restrictions.Length); foreach (Restriction restriction3 in orRestriction.Restrictions) { this.WriteRestriction(restriction3); } return; } if (restriction is Restriction.NotRestriction) { Restriction.NotRestriction notRestriction = (Restriction.NotRestriction)restriction; this.WriteInt(2); this.WriteRestriction(notRestriction.Restriction); return; } if (restriction is Restriction.ContentRestriction) { Restriction.ContentRestriction contentRestriction = (Restriction.ContentRestriction)restriction; this.WriteInt(3); this.WriteInt((int)contentRestriction.Flags); this.WriteInt((int)contentRestriction.PropTag); this.WritePropValue(contentRestriction.PropValue.PropTag, contentRestriction.PropValue.Value); return; } if (restriction is Restriction.PropertyRestriction) { Restriction.PropertyRestriction propertyRestriction = (Restriction.PropertyRestriction)restriction; this.WriteInt(4); this.WriteInt((int)propertyRestriction.Op); this.WriteInt((int)propertyRestriction.PropTag); this.WritePropValue(propertyRestriction.PropValue.PropTag, propertyRestriction.PropValue.Value); return; } if (restriction is Restriction.ComparePropertyRestriction) { Restriction.ComparePropertyRestriction comparePropertyRestriction = (Restriction.ComparePropertyRestriction)restriction; this.WriteInt(5); this.WriteInt((int)comparePropertyRestriction.Op); this.WriteInt((int)comparePropertyRestriction.TagLeft); this.WriteInt((int)comparePropertyRestriction.TagRight); return; } if (restriction is Restriction.ExistRestriction) { Restriction.ExistRestriction existRestriction = (Restriction.ExistRestriction)restriction; this.WriteInt(8); this.WriteInt((int)existRestriction.Tag); return; } if (restriction is Restriction.AttachmentRestriction) { Restriction.AttachmentRestriction attachmentRestriction = (Restriction.AttachmentRestriction)restriction; this.WriteInt(9); this.WriteInt(236126221); this.WriteRestriction(attachmentRestriction.Restriction); return; } if (restriction is Restriction.RecipientRestriction) { Restriction.RecipientRestriction recipientRestriction = (Restriction.RecipientRestriction)restriction; this.WriteInt(9); this.WriteInt(236060685); this.WriteRestriction(recipientRestriction.Restriction); return; } throw new ArgumentException(ServerStrings.ExUnknownRestrictionType, "restriction"); }