Exemplo n.º 1
0
        /// <summary>
        /// Creates a new instance of the <see cref="MemberSearch"/> object and performs the search.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="limit">Optional - The result limit.  Can be a value from 1 to 20. The default is 8.</param>
        /// <param name="board">Optional - A board to which the search should be limited.</param>
        /// <param name="organization">Optional - An organization to which the search should be limited.</param>
        /// <param name="restrictToOrganization">Optional - Restricts the search to only organization members.</param>
        /// <param name="auth">(Optional) Custom authorization parameters. When not provided,
        /// <see cref="TrelloAuthorization.Default"/> will be used.</param>
        public MemberSearch(string query, int?limit = null, Board board = null, Organization organization = null, bool?restrictToOrganization = null, TrelloAuthorization auth = null)
        {
            _context = new MemberSearchContext(auth);

            _board = new Field <Board>(_context, nameof(Board));
            _limit = new Field <int?>(_context, nameof(Limit));
            _limit.AddRule(NullableHasValueRule <int> .Instance);
            _limit.AddRule(new NumericRule <int> {
                Min = 1, Max = 20
            });
            _organization = new Field <Organization>(_context, nameof(Organization));
            _query        = new Field <string>(_context, nameof(Query));
            _query.AddRule(NotNullOrWhiteSpaceRule.Instance);
            _restrictToOrganization = new Field <bool?>(_context, nameof(RestrictToOrganization));
            _results = new Field <IEnumerable <MemberSearchResult> >(_context, nameof(Results));

            Query                  = query;
            Limit                  = limit;
            Board                  = board;
            Organization           = organization;
            RestrictToOrganization = restrictToOrganization;
        }