Exemplo n.º 1
0
 private static void GetNodesFromExpressionTree(QueryFilter queryFilter, Hashtable allowedProperties, List <FilterNode> filterNodes)
 {
     if (queryFilter != null)
     {
         CompositeFilter  compositeFilter  = queryFilter as CompositeFilter;
         TextFilter       textFilter       = queryFilter as TextFilter;
         ComparisonFilter comparisonFilter = queryFilter as ComparisonFilter;
         ExistsFilter     existsFilter     = queryFilter as ExistsFilter;
         NotFilter        notFilter        = queryFilter as NotFilter;
         if (compositeFilter != null)
         {
             using (ReadOnlyCollection <QueryFilter> .Enumerator enumerator = compositeFilter.Filters.GetEnumerator())
             {
                 while (enumerator.MoveNext())
                 {
                     QueryFilter queryFilter2 = enumerator.Current;
                     FilterNode.GetNodesFromExpressionTree(queryFilter2, allowedProperties, filterNodes);
                 }
                 return;
             }
         }
         if (notFilter != null)
         {
             textFilter       = (notFilter.Filter as TextFilter);
             existsFilter     = (notFilter.Filter as ExistsFilter);
             comparisonFilter = (notFilter.Filter as ComparisonFilter);
             if ((textFilter == null && existsFilter == null && comparisonFilter == null) || (comparisonFilter != null && !typeof(bool).IsAssignableFrom(comparisonFilter.Property.Type)))
             {
                 throw new InvalidOperationException(Strings.InvalidNotFilter.ToString());
             }
         }
         if (textFilter != null)
         {
             FilterNode.GetNodeFromTextFilter(textFilter, allowedProperties, filterNodes, notFilter != null);
             return;
         }
         if (comparisonFilter != null)
         {
             FilterNode.GetNodeFromComparisonFilter(comparisonFilter, allowedProperties, filterNodes, notFilter != null);
             return;
         }
         if (existsFilter != null)
         {
             FilterNode.GetNodeFromExistsFilter(existsFilter, allowedProperties, filterNodes, null != notFilter);
             return;
         }
         throw new InvalidOperationException(Strings.UnsuportedFilterType(queryFilter.GetType()).ToString());
     }
 }
Exemplo n.º 2
0
        public static List <FilterNode> GetNodesFromSerializedQueryFilter(byte[] serializedQueryFilter, IList <FilterablePropertyDescription> filterableProperties, ObjectSchema schema)
        {
            List <FilterNode> list = new List <FilterNode>();

            if (serializedQueryFilter != null)
            {
                Hashtable hashtable = new Hashtable(filterableProperties.Count);
                foreach (FilterablePropertyDescription filterablePropertyDescription in filterableProperties)
                {
                    hashtable.Add(filterablePropertyDescription.PropertyDefinition.Name, filterablePropertyDescription);
                }
                FilterNode.GetNodesFromExpressionTree((QueryFilter)WinformsHelper.DeSerialize(serializedQueryFilter), hashtable, list);
            }
            return(list);
        }