internal static Restriction BuildIsReadRestriction(SinglePropertyFilter filter, IFilterBuilderHelper mapper)
        {
            ContentFilterSchema.ContentFilterPropertyDefinition contentFilterPropertyDefinition = (ContentFilterSchema.ContentFilterPropertyDefinition)filter.Property;
            PropTag propTagToSearch = contentFilterPropertyDefinition.PropTagToSearch;
            bool    flag;

            ContentFilterBuilder.CheckFilterIsEQorNE(filter, out flag);
            bool flag2 = (bool)ContentFilterBuilder.GetPropertyValue(filter);

            if (flag)
            {
                flag2 = !flag2;
            }
            if (!flag2)
            {
                return(Restriction.BitMaskZero(propTagToSearch, 1));
            }
            return(Restriction.BitMaskNonZero(propTagToSearch, 1));
        }
        private static Restriction BuildRecipientRestrictionInternal(SinglePropertyFilter filter, IFilterBuilderHelper mapper, PropTag ptagToSearch)
        {
            List <Restriction> list = new List <Restriction>();
            bool flag;

            ContentFilterBuilder.CheckFilterIsEQorNE(filter, out flag);
            object propertyValue = ContentFilterBuilder.GetPropertyValue(filter);

            list.Add(Restriction.Content(ptagToSearch, propertyValue, ContentFlags.Prefix | ContentFlags.IgnoreCase));
            string text = propertyValue as string;

            if (text != null)
            {
                string[] array = mapper.MapRecipient(text);
                if (array != null)
                {
                    foreach (string text2 in array)
                    {
                        if (!StringComparer.OrdinalIgnoreCase.Equals(text2, text))
                        {
                            list.Add(Restriction.Content(ptagToSearch, text2, ContentFlags.Prefix | ContentFlags.IgnoreCase));
                        }
                    }
                }
            }
            Restriction restriction;

            if (list.Count == 1)
            {
                restriction = list[0];
            }
            else
            {
                restriction = Restriction.Or(list.ToArray());
            }
            if (!flag)
            {
                return(restriction);
            }
            return(Restriction.Not(restriction));
        }
        internal static Restriction BuildIsFlaggedRestriction(SinglePropertyFilter filter, IFilterBuilderHelper mapper)
        {
            ContentFilterSchema.ContentFilterPropertyDefinition contentFilterPropertyDefinition = (ContentFilterSchema.ContentFilterPropertyDefinition)filter.Property;
            PropTag propTagToSearch = contentFilterPropertyDefinition.PropTagToSearch;
            bool    flag;

            ContentFilterBuilder.CheckFilterIsEQorNE(filter, out flag);
            bool flag2 = (bool)ContentFilterBuilder.GetPropertyValue(filter);

            if (flag)
            {
                flag2 = !flag2;
            }
            Restriction restriction = Restriction.EQ(propTagToSearch, 2);

            if (!flag2)
            {
                return(Restriction.Not(restriction));
            }
            return(restriction);
        }
        private static Restriction BuildPolicyTagRestrictionInternal(SinglePropertyFilter filter, IFilterBuilderHelper mapper, PropTag ptagToSearch)
        {
            bool flag;

            ContentFilterBuilder.CheckFilterIsEQorNE(filter, out flag);
            List <Restriction> list = new List <Restriction>();
            string             text = (string)ContentFilterBuilder.GetPropertyValue(filter);

            if (ContentFilterBuilder.guidRegex.Match(text).Success)
            {
                try
                {
                    Guid guid = new Guid(text);
                    list.Add(Restriction.EQ(ptagToSearch, guid.ToByteArray()));
                }
                catch (FormatException)
                {
                }
            }
            if (list.Count == 0)
            {
                Guid[] array = mapper.MapPolicyTag(text);
                if (array != null)
                {
                    foreach (Guid guid2 in array)
                    {
                        list.Add(Restriction.EQ(ptagToSearch, guid2.ToByteArray()));
                    }
                }
            }
            Restriction restriction = (list.Count == 1) ? list[0] : Restriction.Or(list.ToArray());

            if (!flag)
            {
                return(restriction);
            }
            return(Restriction.Not(restriction));
        }
        private static Restriction BuildMessageKindRestrictionInternal(SinglePropertyFilter filter, IFilterBuilderHelper mapper, PropTag ptagToSearch)
        {
            List <string> list = new List <string>();
            bool          flag;

            ContentFilterBuilder.CheckFilterIsEQorNE(filter, out flag);
            switch ((MessageKindEnum)ContentFilterBuilder.GetPropertyValue(filter))
            {
            case MessageKindEnum.Email:
                list.Add("IPM.Note");
                break;

            case MessageKindEnum.Calendar:
                list.Add("IPM.Schedule");
                list.Add("IPM.Appointment");
                break;

            case MessageKindEnum.Task:
                list.Add("IPM.Task");
                break;

            case MessageKindEnum.Note:
                list.Add("IPM.StickyNote");
                break;

            case MessageKindEnum.Doc:
                list.Add("IPM.Document");
                break;

            case MessageKindEnum.Journal:
                list.Add("IPM.Activity");
                break;

            case MessageKindEnum.Contact:
                list.Add("IPM.Contact");
                break;

            case MessageKindEnum.InstantMessage:
                list.Add("IPM.Note.Microsoft.Conversation");
                list.Add("IPM.Note.Microsoft.Missed");
                list.Add("IPM.Note.Microsoft.Conversation.Voice");
                list.Add("IPM.Note.Microsoft.Missed.Voice");
                break;

            case MessageKindEnum.Voicemail:
                list.Add("IPM.Note.Microsoft.Voicemail");
                break;

            case MessageKindEnum.Fax:
                list.Add("IPM.Note.Microsoft.Fax");
                break;

            case MessageKindEnum.Post:
                list.Add("IPM.Post");
                break;

            case MessageKindEnum.RSSFeed:
                list.Add("IPM.Post.RSS");
                break;

            default:
                throw ContentFilterBuilder.UnexpectedFilterType(filter);
            }
            Restriction[] array = new Restriction[list.Count];
            for (int i = 0; i < list.Count; i++)
            {
                array[i] = Restriction.EQ(ptagToSearch, list[i]);
            }
            Restriction restriction = (array.Length == 1) ? array[0] : Restriction.Or(array);

            if (!flag)
            {
                return(restriction);
            }
            return(Restriction.Not(restriction));
        }
 private static Restriction BuildPropertyRestrictionInternal(SinglePropertyFilter filter, IFilterBuilderHelper mapper, PropTag ptagToSearch)
 {
     return(ContentFilterBuilder.BuildBasicRestriction(filter, ptagToSearch, ContentFilterBuilder.GetPropertyValue(filter)));
 }