コード例 #1
0
        private Restriction FixRestriction(Restriction restriction)
        {
            if (restriction == null)
            {
                return(null);
            }
            switch (restriction.Type)
            {
            case Restriction.ResType.And:
            {
                Restriction.AndRestriction andRestriction = (Restriction.AndRestriction)restriction;
                andRestriction.Restrictions = this.FixRestrictions(andRestriction.Restrictions);
                break;
            }

            case Restriction.ResType.Or:
            {
                Restriction.OrRestriction orRestriction = (Restriction.OrRestriction)restriction;
                orRestriction.Restrictions = this.FixRestrictions(orRestriction.Restrictions);
                break;
            }

            case Restriction.ResType.Not:
            {
                Restriction.NotRestriction notRestriction = (Restriction.NotRestriction)restriction;
                notRestriction.Restriction = this.FixRestriction(notRestriction.Restriction);
                break;
            }

            case Restriction.ResType.Property:
            {
                Restriction.PropertyRestriction propertyRestriction = (Restriction.PropertyRestriction)restriction;
                propertyRestriction.PropValue = this.FixProperty(propertyRestriction.PropValue);
                break;
            }

            case Restriction.ResType.SubRestriction:
            {
                Restriction.SubRestriction subRestriction = (Restriction.SubRestriction)restriction;
                subRestriction.Restriction = this.FixRestriction(subRestriction.Restriction);
                break;
            }

            case Restriction.ResType.Comment:
            {
                Restriction.CommentRestriction commentRestriction = (Restriction.CommentRestriction)restriction;
                commentRestriction.Restriction = this.FixRestriction(commentRestriction.Restriction);
                break;
            }

            case Restriction.ResType.Count:
            {
                Restriction.CountRestriction countRestriction = (Restriction.CountRestriction)restriction;
                countRestriction.Restriction = this.FixRestriction(countRestriction.Restriction);
                break;
            }
            }
            return(restriction);
        }
コード例 #2
0
        private static bool EvaluateAndRestriction(Restriction.AndRestriction restriction, IRuleEvaluationContext context)
        {
            bool flag = true;

            context.NestedLevel++;
            foreach (Restriction restriction2 in restriction.Restrictions)
            {
                if (!RestrictionEvaluator.Evaluate(restriction2, context))
                {
                    flag = false;
                    break;
                }
            }
            context.NestedLevel--;
            context.TraceFunction <bool>("AndRestriction evaluated to {0}", flag);
            return(flag);
        }
コード例 #3
0
        private static void DumpRestriction(StringBuilder sb, Restriction restriction)
        {
            if (restriction == null)
            {
                return;
            }
            sb.Append("(");
            Restriction.ResType type = restriction.Type;
            switch (type)
            {
            case Restriction.ResType.And:
            {
                Restriction.AndRestriction andRestriction = (Restriction.AndRestriction)restriction;
                sb.Append("AND ");
                foreach (Restriction restriction2 in andRestriction.Restrictions)
                {
                    GetFolderRestriction.DumpRestriction(sb, restriction2);
                }
                break;
            }

            case Restriction.ResType.Or:
            {
                Restriction.OrRestriction orRestriction = (Restriction.OrRestriction)restriction;
                sb.Append("OR ");
                foreach (Restriction restriction3 in orRestriction.Restrictions)
                {
                    GetFolderRestriction.DumpRestriction(sb, restriction3);
                }
                break;
            }

            case Restriction.ResType.Not:
            {
                Restriction.NotRestriction notRestriction = (Restriction.NotRestriction)restriction;
                sb.Append("NOT ");
                GetFolderRestriction.DumpRestriction(sb, notRestriction.Restriction);
                break;
            }

            case Restriction.ResType.Content:
            {
                Restriction.ContentRestriction contentRestriction = (Restriction.ContentRestriction)restriction;
                sb.AppendFormat("CONTENT flags:{0} mv:{1} propTag:{2:X} propValue:(", contentRestriction.Flags, contentRestriction.MultiValued, contentRestriction.PropTag);
                GetFolderRestriction.DumpPropValue(sb, contentRestriction.PropValue);
                sb.Append(")");
                break;
            }

            case Restriction.ResType.Property:
            {
                Restriction.PropertyRestriction propertyRestriction = (Restriction.PropertyRestriction)restriction;
                sb.AppendFormat("PROPERTY Op:{0}, propTag:{1:X} propValue:", propertyRestriction.Op, propertyRestriction.PropTag);
                GetFolderRestriction.DumpPropValue(sb, propertyRestriction.PropValue);
                break;
            }

            case Restriction.ResType.CompareProps:
            {
                Restriction.ComparePropertyRestriction comparePropertyRestriction = (Restriction.ComparePropertyRestriction)restriction;
                sb.AppendFormat("COMPPROPS Op:{0} propTag1:{1:X} propTag2:{2:X}", comparePropertyRestriction.Op, comparePropertyRestriction.TagLeft, comparePropertyRestriction.TagRight);
                break;
            }

            case Restriction.ResType.BitMask:
            {
                Restriction.BitMaskRestriction bitMaskRestriction = (Restriction.BitMaskRestriction)restriction;
                sb.AppendFormat("BITMASK Bmr:{0} Mask:{1:X} propTag:{2:X}", bitMaskRestriction.Bmr, bitMaskRestriction.Mask, bitMaskRestriction.Tag);
                break;
            }

            case Restriction.ResType.Size:
            {
                Restriction.SizeRestriction sizeRestriction = (Restriction.SizeRestriction)restriction;
                sb.AppendFormat("SIZE propTag:{0:X} Op:{1} size:{2}", sizeRestriction.Tag, sizeRestriction.Op, sizeRestriction.Size);
                break;
            }

            case Restriction.ResType.Exist:
            {
                Restriction.ExistRestriction existRestriction = (Restriction.ExistRestriction)restriction;
                sb.AppendFormat("EXIST propTag:{0:X}", existRestriction.Tag);
                break;
            }

            case Restriction.ResType.SubRestriction:
            {
                Restriction.SubRestriction subRestriction = (Restriction.SubRestriction)restriction;
                sb.Append("SUBRESTRICTION ");
                GetFolderRestriction.DumpRestriction(sb, subRestriction.Restriction);
                break;
            }

            case Restriction.ResType.Comment:
            {
                Restriction.CommentRestriction commentRestriction = (Restriction.CommentRestriction)restriction;
                sb.AppendFormat("COMMENT values:{0} ", commentRestriction.Values.Length);
                foreach (PropValue v in commentRestriction.Values)
                {
                    GetFolderRestriction.DumpPropValue(sb, v);
                }
                GetFolderRestriction.DumpRestriction(sb, commentRestriction.Restriction);
                break;
            }

            case Restriction.ResType.Count:
            {
                Restriction.CountRestriction countRestriction = (Restriction.CountRestriction)restriction;
                sb.AppendFormat("COUNT {0} ", countRestriction.Count);
                GetFolderRestriction.DumpRestriction(sb, countRestriction.Restriction);
                break;
            }

            default:
                switch (type)
                {
                case Restriction.ResType.True:
                    sb.Append("TRUE");
                    break;

                case Restriction.ResType.False:
                    sb.Append("FALSE");
                    break;

                default:
                    sb.AppendFormat("<UNKNOWN RESTYPE:{0}>", restriction.Type);
                    break;
                }
                break;
            }
            sb.Append(")");
        }
コード例 #4
0
 private static bool Equals(Restriction.AndRestriction a, Restriction.AndRestriction b)
 {
     return(ConditionComparer.Equals(a.Restrictions, b.Restrictions));
 }
コード例 #5
0
 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");
 }
コード例 #6
0
 internal AndRestrictionData(Restriction.AndRestriction r)
 {
     base.ParseRestrictions(r.Restrictions);
 }