public IEnumerable <Expression <Func <T, bool> > > GetFiltersFor <T>() where T : class
        {
            var gen = new ExpressionGenerator <T>();

            List <Expression <Func <T, bool> > > opts = gen.ToStrongExpressions(Filters);

            if (!string.IsNullOrEmpty(SearchTerm))
            {
                var ex = ExpressionStore.GetSearchExpression <T>(SearchTerm);
                if (ex != null)
                {
                    opts.Add(ex);
                }
                else if (typeof(T).Implements(typeof(INamed)))
                {
                    Expression <Func <T, bool> > iex = e => ((INamed)e).Name.Contains(SearchTerm);
                    opts.Add(iex);
                }
            }
            return(opts);
        }
Beispiel #2
0
        public static void RegisterExpressions()
        {
            ExpressionStore.RegisterSearchExpression <PageListDTO>(term =>
                                                                   e => e.ViewPath.Contains(term) || e.PageCategoryName.Contains(term) || e.BaseComponent.Contains(term));

            ExpressionStore.RegisterSearchExpression <PageCategoryListDTO>(term => e => e.Name.Contains(term) || e.BaseComponent.Contains(term) || e.ResourceName.Contains(term));

            ExpressionStore.RegisterSearchExpression <NavigationGroupDTO>(term => e => e.Name.Contains(term));

            ExpressionStore.RegisterSearchExpression <NavigationPageDTO>(term => e => e.Url.Contains(term));

            ExpressionStore.RegisterSearchExpression <NavigationPageListDTO>(term => e => e.Url.Contains(term) ||
                                                                             e.Name.Contains(term));

            ExpressionStore.RegisterSearchExpression <PageControlListDTO>(term => e =>
                                                                          e.PageName.Contains(term) || e.ControlIdentifier.Contains(term) || e.ControlType.Contains(term));

            ExpressionStore.RegisterSearchExpression <ResourceListDTO>(term => e => e.Name.Contains(term) || e.Domain.Contains(term));

            ExpressionStore.RegisterSearchExpression <PageReferenceDTO>(term =>
                                                                        e => e.PageViewPath.Contains(term) || e.ParameterName.Contains(term) || e.ReferencedPageViewPath.Contains(term) || e.PageCategoryViewPath.Contains(term));
        }
Beispiel #3
0
 public static void RegisterExpressions()
 {
     ExpressionStore.RegisterSearchExpression <User>(term => e =>
                                                     e.Name.Contains(term) || e.Email.Contains(term) || e.Mobile.Contains(term)
                                                     );
 }