internal static Restriction BuildAttachmentRestriction(SinglePropertyFilter filter, IFilterBuilderHelper mapper)
        {
            Restriction restriction  = ContentFilterBuilder.BuildRestrictionWrapper(filter, PropTag.SearchAttachments, mapper, new ContentFilterBuilder.BuildRestrictionDelegate(ContentFilterBuilder.BuildPropertyRestrictionInternal));
            Restriction restriction2 = Restriction.Or(new Restriction[]
            {
                ContentFilterBuilder.BuildRestrictionWrapper(filter, PropTag.AttachFileName, mapper, new ContentFilterBuilder.BuildRestrictionDelegate(ContentFilterBuilder.BuildPropertyRestrictionInternal)),
                ContentFilterBuilder.BuildRestrictionWrapper(filter, PropTag.AttachLongFileName, mapper, new ContentFilterBuilder.BuildRestrictionDelegate(ContentFilterBuilder.BuildPropertyRestrictionInternal)),
                ContentFilterBuilder.BuildRestrictionWrapper(filter, PropTag.AttachExtension, mapper, new ContentFilterBuilder.BuildRestrictionDelegate(ContentFilterBuilder.BuildPropertyRestrictionInternal)),
                ContentFilterBuilder.BuildRestrictionWrapper(filter, PropTag.DisplayName, mapper, new ContentFilterBuilder.BuildRestrictionDelegate(ContentFilterBuilder.BuildPropertyRestrictionInternal))
            });

            return(Restriction.Or(new Restriction[]
            {
                restriction,
                Restriction.Sub(PropTag.MessageAttachments, restriction2)
            }));
        }
 internal override Restriction GetRestriction()
 {
     return(Restriction.Sub(PropTag.MessageRecipients, base.GetRestrictions()[0]));
 }
示例#3
0
        internal static Restriction ConvertToMapiRestriction(Restriction restriction)
        {
            if (restriction == null)
            {
                return(null);
            }
            switch (restriction.RestrictionType)
            {
            case RestrictionType.And:
                return(Restriction.And(ConvertHelper.ConvertToMapiRestrictions(((CompositeRestriction)restriction).ChildRestrictions)));

            case RestrictionType.Or:
                return(Restriction.Or(ConvertHelper.ConvertToMapiRestrictions(((CompositeRestriction)restriction).ChildRestrictions)));

            case RestrictionType.Not:
                return(Restriction.Not(ConvertHelper.ConvertToMapiRestriction(((NotRestriction)restriction).ChildRestriction)));

            case RestrictionType.Content:
            {
                ContentRestriction contentRestriction = restriction as ContentRestriction;
                if (contentRestriction.PropertyValue == null)
                {
                    throw new NspiException(NspiStatus.InvalidParameter, "Null PropertyValue is not valid for ContentRestriction.");
                }
                return(Restriction.Content(ConvertHelper.ConvertToMapiPropTag(contentRestriction.PropertyTag), contentRestriction.PropertyTag.IsMultiValuedProperty, ConvertHelper.ConvertToMapiPropValue(contentRestriction.PropertyValue.Value), (ContentFlags)contentRestriction.FuzzyLevel));
            }

            case RestrictionType.Property:
            {
                PropertyRestriction propertyRestriction = restriction as PropertyRestriction;
                if (propertyRestriction.PropertyValue == null)
                {
                    throw new NspiException(NspiStatus.InvalidParameter, "Null PropertyValue is not valid for PropertyRestriction.");
                }
                return(Restriction.Property(ConvertHelper.ConvertToMapiRelOp(propertyRestriction.RelationOperator), ConvertHelper.ConvertToMapiPropTag(propertyRestriction.PropertyTag), propertyRestriction.PropertyTag.IsMultiValuedProperty, ConvertHelper.ConvertToMapiPropValue(propertyRestriction.PropertyValue.Value)));
            }

            case RestrictionType.CompareProps:
            {
                ComparePropsRestriction comparePropsRestriction = restriction as ComparePropsRestriction;
                return(Restriction.CompareProps(ConvertHelper.ConvertToMapiRelOp(comparePropsRestriction.RelationOperator), ConvertHelper.ConvertToMapiPropTag(comparePropsRestriction.Property1), ConvertHelper.ConvertToMapiPropTag(comparePropsRestriction.Property2)));
            }

            case RestrictionType.BitMask:
            {
                BitMaskRestriction bitMaskRestriction = restriction as BitMaskRestriction;
                return(Restriction.BitMask(ConvertHelper.ConvertToMapiRelBmr(bitMaskRestriction.BitMaskOperator), ConvertHelper.ConvertToMapiPropTag(bitMaskRestriction.PropertyTag), (int)bitMaskRestriction.BitMask));
            }

            case RestrictionType.Size:
            {
                SizeRestriction sizeRestriction = restriction as SizeRestriction;
                return(Restriction.PropertySize(ConvertHelper.ConvertToMapiRelOp(sizeRestriction.RelationOperator), ConvertHelper.ConvertToMapiPropTag(sizeRestriction.PropertyTag), (int)sizeRestriction.Size));
            }

            case RestrictionType.Exists:
            {
                ExistsRestriction existsRestriction = restriction as ExistsRestriction;
                return(Restriction.Exist(ConvertHelper.ConvertToMapiPropTag(existsRestriction.PropertyTag)));
            }

            case RestrictionType.SubRestriction:
            {
                SubRestriction subRestriction = restriction as SubRestriction;
                return(Restriction.Sub(ConvertHelper.ConvertToMapiPropTag(subRestriction.SubRestrictionType), ConvertHelper.ConvertToMapiRestriction(subRestriction.ChildRestriction)));
            }

            default:
                throw new NspiException(NspiStatus.InvalidParameter, string.Format("Invalid restriction type: {0}", restriction));
            }
        }
        internal Restriction ReadRestriction()
        {
            OutlookBlobWriter.RestrictionType restrictionType = (OutlookBlobWriter.RestrictionType) this.ReadInt();
            switch (restrictionType)
            {
            case OutlookBlobWriter.RestrictionType.And:
            case OutlookBlobWriter.RestrictionType.Or:
            {
                int           num   = this.ReadInt();
                Restriction[] array = new Restriction[num];
                for (int i = 0; i < num; i++)
                {
                    array[i] = this.ReadRestriction();
                }
                if (restrictionType == OutlookBlobWriter.RestrictionType.And)
                {
                    return(Restriction.And(array));
                }
                return(Restriction.Or(array));
            }

            case OutlookBlobWriter.RestrictionType.Not:
                return(Restriction.Not(this.ReadRestriction()));

            case OutlookBlobWriter.RestrictionType.Content:
            {
                ContentFlags flags = (ContentFlags)this.ReadInt();
                PropTag      tag   = (PropTag)this.ReadInt();
                return(Restriction.Content(tag, this.ReadPropValue().Value, flags));
            }

            case OutlookBlobWriter.RestrictionType.Property:
            {
                Restriction.RelOp relOp = (Restriction.RelOp) this.ReadInt();
                PropTag           tag2  = (PropTag)this.ReadInt();
                return(new Restriction.PropertyRestriction(relOp, tag2, this.ReadPropValue().Value));
            }

            case OutlookBlobWriter.RestrictionType.PropertyComparison:
            {
                Restriction.RelOp relOp2   = (Restriction.RelOp) this.ReadInt();
                PropTag           tagLeft  = (PropTag)this.ReadInt();
                PropTag           tagRight = (PropTag)this.ReadInt();
                return(new Restriction.ComparePropertyRestriction(relOp2, tagLeft, tagRight));
            }

            case OutlookBlobWriter.RestrictionType.Bitmask:
                if (this.ReadInt() == 0)
                {
                    return(Restriction.BitMaskZero((PropTag)this.ReadInt(), this.ReadInt()));
                }
                return(Restriction.BitMaskNonZero((PropTag)this.ReadInt(), this.ReadInt()));

            case OutlookBlobWriter.RestrictionType.Size:
            {
                Restriction.RelOp relop = (Restriction.RelOp) this.ReadInt();
                PropTag           tag3  = (PropTag)this.ReadInt();
                int size = this.ReadInt();
                return(new Restriction.SizeRestriction(relop, tag3, size));
            }

            case OutlookBlobWriter.RestrictionType.Exist:
            {
                PropTag tag4 = (PropTag)this.ReadInt();
                return(Restriction.Exist(tag4));
            }

            case OutlookBlobWriter.RestrictionType.Subfilter:
            {
                PropTag propTag = (PropTag)this.ReadInt();
                if (propTag == PropTag.MessageAttachments || propTag == PropTag.MessageRecipients)
                {
                    return(Restriction.Sub(propTag, this.ReadRestriction()));
                }
                throw new CorruptDataException(ServerStrings.ExUnknownRestrictionType);
            }

            default:
                throw new CorruptDataException(ServerStrings.ExUnknownRestrictionType);
            }
        }