예제 #1
0
        protected virtual void OnFilterHasChanged(Object sender, PropertyChangedEventArgs e)
        {
            if (e != null && e.PropertyName != "AmbethFilterDescriptor")
            {
                return;
            }
            IFilterDescriptorProvider[] filterList = providerList.GetExtensions();

            if (filterList.Length == 0)
            {
                AmbethFilterDescriptor = null;
                return;
            }

            AmbethIFilterDescriptor filter = CopyFilterDescriptor(filterList[0].AmbethFilterDescriptor);

            for (int i = 1, length = filterList.Length; i < length; i++)
            {
                filter = FilterDescriptorConverter.Compose(filter, CopyFilterDescriptor(filterList[i].AmbethFilterDescriptor));
            }
            AmbethFilterDescriptor = filter;
        }
예제 #2
0
 protected virtual AmbethIFilterDescriptor CopyFilterDescriptor(AmbethIFilterDescriptor filterToCopy)
 {
     if (filterToCopy == null)
     {
         return(null);
     }
     if (filterToCopy is CompositeFilterDescriptor)
     {
         var filter = new CompositeFilterDescriptor();
         if (filterToCopy.ChildFilterDescriptors != null)
         {
             filter.ChildFilterDescriptors = new List <AmbethIFilterDescriptor>();
             foreach (var child in filterToCopy.ChildFilterDescriptors)
             {
                 filter.ChildFilterDescriptors.Add(CopyFilterDescriptor(child));
             }
         }
         filter.LogicalOperator = filterToCopy.LogicalOperator;
         return(filter);
     }
     else
     {
         var filter = new FilterDescriptor();
         filter.IsCaseSensitive = filterToCopy.IsCaseSensitive;
         filter.Member          = filterToCopy.Member;
         filter.Operator        = filterToCopy.Operator;
         if (filterToCopy.Value != null)
         {
             filter.Value = new List <String>();
             foreach (var val in filterToCopy.Value)
             {
                 filter.Value.Add(val);
             }
         }
         return(filter);
     }
 }