Exemplo n.º 1
0
        /// <summary>
        /// Filters a <see cref="ReadOnlyActionCollection"/> for a given <see cref="ActionType"/>s.
        /// </summary>
        /// <param name="actions">The <see cref="ReadOnlyActionCollection"/></param>
        /// <param name="filters">The new <see cref="ActionType"/>s by which to filter.</param>
        /// <returns>The filtered collection.</returns>
        /// <exception cref="ArgumentException">Thrown when <see cref="ActionType.Unknown"/> is included in the filter.</exception>
        /// <remarks>The new filter parameters will function as OR parameters.</remarks>
        public static ReadOnlyActionCollection Filter(this ReadOnlyActionCollection actions, IEnumerable <ActionType> filters)
        {
            if (filters.Any(f => f == ActionType.Unknown))
            {
                throw new ArgumentException($"Action type '{ActionType.Unknown}' is not recognized by the Trello API.  Please remove it from the filters.", nameof(filters));
            }

            var collection = new ReadOnlyActionCollection(actions, actions.Auth);

            collection.AddFilter(filters);
            return(collection);
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="actions">The <see cref="ReadOnlyActionCollection"/></param>
        /// <param name="start">The desired start date.</param>
        /// <param name="end">The desired end date.</param>
        /// <exception cref="ArgumentException">Thrown when <see cref="ActionType.Unknown"/> is included in the filter.</exception>
        /// <returns>The filtered collection.</returns>
        public static ReadOnlyActionCollection Filter(this ReadOnlyActionCollection actions, DateTime?start = null, DateTime?end = null)
        {
            if (!start.HasValue && !end.HasValue)
            {
                throw new ArgumentException("Must pass a start and/or end date.");
            }

            var collection = new ReadOnlyActionCollection(actions, actions.Auth);

            collection.AddFilter(start, end);
            return(collection);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Filters a <see cref="ReadOnlyActionCollection"/> for a given <see cref="ActionType"/>.
        /// </summary>
        /// <param name="actions">The <see cref="ReadOnlyActionCollection"/></param>
        /// <param name="filter">The new <see cref="ActionType"/> by which to filter.  Can be combined using the bitwise OR operator.</param>
        /// <returns>The filtered collection.</returns>
        /// <exception cref="ArgumentException">Thrown when <see cref="ActionType.Unknown"/> is included in the filter.</exception>
        /// <remarks>The new filter parameter will function as an OR parameter.</remarks>
        public static ReadOnlyActionCollection Filter(this ReadOnlyActionCollection actions, ActionType filter)
        {
            if (filter == ActionType.Unknown)
            {
                throw new ArgumentException($"Action type '{ActionType.Unknown}' is not recognized by the Trello API.  Please indicate a different filter.", nameof(filter));
            }

            var collection = new ReadOnlyActionCollection(actions, actions.Auth);

            collection.AddFilter(new[] { filter });
            return(collection);
        }