Example #1
0
        /// <summary>
        /// Creates a new instance of the <see cref="Search"/> object and performs the search.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="limit">The maximum number of results to return.</param>
        /// <param name="modelTypes">(Optional) The desired model types to return.  Can be joined using the | operator.  Default is All.</param>
        /// <param name="context">(Optional) A collection of queryable items to serve as a context in which to search.</param>
        /// <param name="auth">(Optional) Custom authorization parameters. When not provided,
        /// <see cref="TrelloAuthorization.Default"/> will be used.</param>
        /// <param name="isPartial">(Optional) Indicates whether to include matches that <em>start with</em> the query text.  Default is false.</param>
        public Search(string query, int?limit          = null, SearchModelType modelTypes = SearchModelType.All,
                      IEnumerable <IQueryable> context = null, TrelloAuthorization auth   = null, bool isPartial = false)
        {
            _context = new SearchContext(auth);

            _actions       = new Field <IEnumerable <Action> >(_context, nameof(Actions));
            _boards        = new Field <IEnumerable <Board> >(_context, nameof(Boards));
            _cards         = new Field <IEnumerable <Card> >(_context, nameof(Cards));
            _members       = new Field <IEnumerable <Member> >(_context, nameof(Members));
            _organizations = new Field <IEnumerable <Organization> >(_context, nameof(Organizations));
            _query         = new Field <string>(_context, nameof(Query));
            _query.AddRule(NotNullOrWhiteSpaceRule.Instance);
            _queryContext = new Field <List <IQueryable> >(_context, nameof(Context));
            _modelTypes   = new Field <SearchModelType?>(_context, nameof(Types));
            _limit        = new Field <int?>(_context, nameof(Limit));
            _limit.AddRule(NullableHasValueRule <int> .Instance);
            _limit.AddRule(new NumericRule <int> {
                Min = 1, Max = 1000
            });
            _isPartial = new Field <bool?>(_context, nameof(IsPartial));

            Query = query;
            if (context != null)
            {
                Context = context.ToList();
            }
            Types     = modelTypes;
            Limit     = limit;
            IsPartial = isPartial;
        }
Example #2
0
 /// <summary>
 /// Creates a new instance of the <see cref="Search"/> object and performs the search.
 /// </summary>
 /// <param name="query">The query.</param>
 /// <param name="limit">The maximum number of results to return.</param>
 /// <param name="modelTypes">(Optional) The desired model types to return.  Can be joined using the | operator.  Default is All.</param>
 /// <param name="context">(Optional) A collection of queryable items to serve as a context in which to search.</param>
 /// <param name="auth">(Optional) Custom authorization parameters. When not provided,
 /// <see cref="TrelloAuthorization.Default"/> will be used.</param>
 /// <param name="isPartial">(Optional) Indicates whether to include matches that <em>start with</em> the query text.  Default is false.</param>
 public Search(ISearchQuery query, int?limit    = null, SearchModelType modelTypes = SearchModelType.All,
               IEnumerable <IQueryable> context = null, TrelloAuthorization auth   = null, bool isPartial = false)
     : this(query.ToString(), limit, modelTypes, context, auth, isPartial)
 {
 }
 /// <summary>
 /// Creates an <see cref="ISearch"/>.
 /// </summary>
 /// <param name="query">The search query.</param>
 /// <param name="limit">(Optional) The maximum number of items to return.</param>
 /// <param name="modelTypes">(Optional) The model types desired.</param>
 /// <param name="context">(Optional) The context (scope) of the search.</param>
 /// <param name="isPartial">(Optional) Allow "starts with" matches.</param>
 /// <param name="auth">(Optional) The authorization.</param>
 /// <returns>An <see cref="ISearch"/></returns>
 public ISearch Search(string query, int?limit          = null, SearchModelType modelTypes = SearchModelType.All,
                       IEnumerable <IQueryable> context = null, bool isPartial             = false, TrelloAuthorization auth = null)
 {
     return(new Search(query, limit, modelTypes, context, auth, isPartial));
 }