Example #1
0
        private IEnumerable <BehaviorChain> getChainsWithoutOutput()
        {
            var filter = new JsonGridFilter {
                ColumnName = _viewFilter.Column.Name(), Values = new[] { ViewColumn.None }
            };

            return(_graph
                   .Behaviors
                   .Where(chain => _viewFilter.AppliesTo(chain, filter) &&
                          _viewFilter.Matches(chain, filter)));
        }
Example #2
0
        public JsonAutocompleteResultModel Post(AutocompleteRequestModel <BehaviorGraph> request)
        {
            var filter = new JsonGridFilter {
                ColumnName = request.Column, Values = new List <string> {
                    request.Query
                }
            };
            var query = JsonGridQuery.ForFilter(filter);

            return(new JsonAutocompleteResultModel
            {
                Values = _gridService
                         .GridFor(_behaviorGraph, query)
                         .Rows
                         .SelectMany(r => r.Columns.Where(c => c.Name.Equals(request.Column, StringComparison.OrdinalIgnoreCase)))
                         .Distinct()
            });
        }
Example #3
0
        public JsonAutocompleteResultModel Execute(AutocompleteRequestModel <RequestCacheModel> request)
        {
            var model  = _modelBuilder.Build();
            var filter = new JsonGridFilter {
                ColumnName = request.Column, Values = new List <string> {
                    request.Query
                }
            };
            var query = JsonGridQuery.ForFilter(filter);

            return(new JsonAutocompleteResultModel
            {
                Values = _gridService
                         .GridFor(model, query)
                         .Rows
                         .SelectMany(r => r.Columns.Where(c => c.Name.Equals(request.Column, StringComparison.OrdinalIgnoreCase)))
                         .Distinct()
            });
        }
Example #4
0
 protected bool contains(TModel target, JsonGridFilter filter)
 {
     return(filter.Matches(_column.ValueFor(target), (filterValue, value) => value.Contains(filterValue)));
 }
Example #5
0
 protected bool startsWith(TModel target, JsonGridFilter filter)
 {
     return(filter.Matches(_column.ValueFor(target), (filterValue, value) => value.StartsWith(filterValue)));
 }
Example #6
0
 public virtual bool Matches(TModel target, JsonGridFilter filter)
 {
     return(contains(target, filter));
 }
Example #7
0
 public virtual bool AppliesTo(TModel target, JsonGridFilter filter)
 {
     return(filter.ColumnName.Equals(_column.Name(), StringComparison.OrdinalIgnoreCase));
 }
Example #8
0
        public static IEnumerable <JsonGridRow> ApplyFilter(this IEnumerable <JsonGridRow> rows, JsonGridFilter filter)
        {
            var filteredRows = new List <JsonGridRow>();

            rows
            .Each(row =>
            {
                if (!row.Columns.Any(c => c.Name.ToLower().Equals(filter.ColumnName.ToLower())))
                {
                    return;
                }

                // TODO: We should do some better matching here
                if (row.Columns.Any(c => filter.Values.Any(value => c.Value.ToLower().Contains(value.ToLower()))))
                {
                    filteredRows.Add(row);
                }
            });

            return(filteredRows);
        }
Example #9
0
 public override bool Matches(BehaviorChain target, JsonGridFilter filter)
 {
     return(startsWith(target, filter));
 }
Example #10
0
 public bool Matches(BehaviorChain target, JsonGridFilter filter)
 {
     return(target.InputType() != null && filter.Values.Any(v => target.InputType().Name.ToLower().Contains(v.ToLower())));
 }
Example #11
0
 public bool AppliesTo(BehaviorChain target, JsonGridFilter filter)
 {
     return(filter.ColumnName.Equals("InputModel", StringComparison.OrdinalIgnoreCase));
 }