Exemple #1
0
        /// <summary>
        /// Creates a new instance of the <see cref="Board"/> object.
        /// </summary>
        /// <param name="id">The board's ID.</param>
        /// <param name="auth">(Optional) Custom authorization parameters. When not provided,
        /// <see cref="TrelloAuthorization.Default"/> will be used.</param>
        public Board(string id, TrelloAuthorization auth = null)
        {
            Auth     = auth;
            _context = new BoardContext(id, auth);
            _context.Synchronized += Synchronized;
            Id = id;

            Actions      = new ReadOnlyActionCollection(typeof(Board), () => Id, auth);
            Cards        = new ReadOnlyCardCollection(typeof(Board), () => Id, auth);
            _description = new Field <string>(_context, nameof(Description));
            _isClosed    = new Field <bool?>(_context, nameof(IsClosed));
            _isClosed.AddRule(NullableHasValueRule <bool> .Instance);
            _isSubscribed = new Field <bool?>(_context, nameof(IsSubscribed));
            _isSubscribed.AddRule(NullableHasValueRule <bool> .Instance);
            Labels      = new BoardLabelCollection(() => Id, auth);
            Lists       = new ListCollection(() => Id, auth);
            Members     = new ReadOnlyMemberCollection(EntityRequestType.Board_Read_Members, () => Id, auth);
            Memberships = new BoardMembershipCollection(() => Id, auth);
            _name       = new Field <string>(_context, nameof(Name));
            _name.AddRule(NotNullOrWhiteSpaceRule.Instance);
            _organization       = new Field <Organization>(_context, nameof(Organization));
            PowerUps            = new ReadOnlyPowerUpCollection(() => Id, auth);
            PowerUpData         = new ReadOnlyPowerUpDataCollection(EntityRequestType.Board_Read_PowerUpData, () => Id, auth);
            Preferences         = new BoardPreferences(_context.BoardPreferencesContext);
            PersonalPreferences = new BoardPersonalPreferences(Id, auth);
            _url = new Field <string>(_context, nameof(Url));

            TrelloConfiguration.Cache.Add(this);
        }
Exemple #2
0
        /// <summary>
        /// Filters a <see cref="ReadOnlyCardCollection"/> for a given <see cref="CardFilter"/>.
        /// </summary>
        /// <param name="cards">The <see cref="ReadOnlyCardCollection"/></param>
        /// <param name="filter">The new <see cref="CardFilter"/> by which to filter.</param>
        /// <returns>The filtered collection.</returns>
        public static ReadOnlyCardCollection Filter(this ReadOnlyCardCollection cards, CardFilter filter)
        {
            var collection = new ReadOnlyCardCollection(cards, cards.Auth);

            collection.SetFilter(filter);
            return(collection);
        }
Exemple #3
0
        /// <summary>
        /// Filters a <see cref="ReadOnlyCardCollection"/> for a given <see cref="CardFilter"/>.
        /// </summary>
        /// <param name="cards">The <see cref="ReadOnlyCardCollection"/></param>
        /// <param name="start">The desired start date.</param>
        /// <param name="end">The desired end date.</param>
        /// <returns>The filtered collection.</returns>
        public static ReadOnlyCardCollection Filter(this ReadOnlyCardCollection cards, DateTime?start = null, DateTime?end = null)
        {
            var collection = new ReadOnlyCardCollection(cards, cards.Auth);

            collection.SetFilter(start, end);
            return(collection);
        }
Exemple #4
0
        /// <summary>
        /// Limits a <see cref="ReadOnlyCardCollection"/> to a specified count of items.
        /// </summary>
        /// <param name="cards">The <see cref="ReadOnlyCardCollection"/></param>
        /// <param name="limit">The limit.</param>
        /// <returns>The limited collection.</returns>
        public static ReadOnlyCardCollection Limit(this ReadOnlyCardCollection cards, int limit)
        {
            if (limit <= 0)
            {
                throw new ArgumentException("limit");
            }

            return(new ReadOnlyCardCollection(cards, cards.Auth)
            {
                Limit = limit
            });
        }
 internal ReadOnlyCardCollection(ReadOnlyCardCollection source, TrelloAuthorization auth)
     : base(() => source.OwnerId, auth)
 {
     _updateRequestType = source._updateRequestType;
     if (source._requestParameters != null)
     {
         _requestParameters = new Dictionary <string, object>(source._requestParameters);
     }
     if (source._additionalParameters != null)
     {
         _additionalParameters = new Dictionary <string, object>(source._additionalParameters);
     }
 }