コード例 #1
0
ファイル: Card.cs プロジェクト: techfooninja/Manatee.Trello
        /// <summary>
        /// Creates a new instance of the <see cref="Card"/> object.
        /// </summary>
        /// <param name="id">The card's ID.</param>
        /// <param name="auth">(Optional) Custom authorization parameters. When not provided, <see cref="TrelloAuthorization.Default"/> will be used.</param>
        /// <remarks>
        /// The supplied ID can be either the full or short ID.
        /// </remarks>
        public Card(string id, TrelloAuthorization auth = null)
        {
            Id       = id;
            _context = new CardContext(id, auth);
            _context.Synchronized.Add(this);

            Badges = new Badges(_context.BadgesContext);
            _board = new Field <Board>(_context, nameof(Board));
            _board.AddRule(NotNullRule <Board> .Instance);
            _description = new Field <string>(_context, nameof(Description));
            _dueDate     = new Field <DateTime?>(_context, nameof(DueDate));
            _isComplete  = new Field <bool?>(_context, nameof(IsComplete));
            _isArchived  = new Field <bool?>(_context, nameof(IsArchived));
            _isArchived.AddRule(NullableHasValueRule <bool> .Instance);
            _isSubscribed = new Field <bool?>(_context, nameof(IsSubscribed));
            _isSubscribed.AddRule(NullableHasValueRule <bool> .Instance);
            _lastActivity = new Field <DateTime?>(_context, nameof(LastActivity));
            _list         = new Field <List>(_context, nameof(List));
            _list.AddRule(NotNullRule <IList> .Instance);
            _name = new Field <string>(_context, nameof(Name));
            _name.AddRule(NotNullOrWhiteSpaceRule.Instance);
            _position = new Field <Position>(_context, nameof(Position));
            _position.AddRule(PositionRule.Instance);
            _shortId  = new Field <int?>(_context, nameof(ShortId));
            _shortUrl = new Field <string>(_context, nameof(ShortUrl));
            _url      = new Field <string>(_context, nameof(Url));

            if (_context.HasValidId && auth != TrelloAuthorization.Null)
            {
                TrelloConfiguration.Cache.Add(this);
            }
        }
コード例 #2
0
        /// <summary>
        /// Creates a new instance of the <see cref="Card"/> object.
        /// </summary>
        /// <param name="id">The card's ID.</param>
        /// <param name="auth">(Optional) Custom authorization parameters. When not provided,
        /// <see cref="TrelloAuthorization.Default"/> will be used.</param>
        /// <remarks>
        /// The supplied ID can be either the full or short ID.
        /// </remarks>
        public Card(string id, TrelloAuthorization auth = null)
        {
            Id       = id;
            _context = new CardContext(id, auth);
            _context.Synchronized += Synchronized;

            Actions     = new ReadOnlyActionCollection(typeof(Card), () => id, auth);
            Attachments = new AttachmentCollection(() => Id, auth);
            Badges      = new Badges(_context.BadgesContext);
            _board      = new Field <Board>(_context, nameof(Board));
            _board.AddRule(NotNullRule <Board> .Instance);
            CheckLists   = new CheckListCollection(this, auth);
            Comments     = new CommentCollection(() => Id, auth);
            _description = new Field <string>(_context, nameof(Description));
            _dueDate     = new Field <DateTime?>(_context, nameof(DueDate));
            _isComplete  = new Field <bool?>(_context, nameof(IsComplete));
            _isArchived  = new Field <bool?>(_context, nameof(IsArchived));
            _isArchived.AddRule(NullableHasValueRule <bool> .Instance);
            _isSubscribed = new Field <bool?>(_context, nameof(IsSubscribed));
            _isSubscribed.AddRule(NullableHasValueRule <bool> .Instance);
            Labels        = new CardLabelCollection(_context, auth);
            _lastActivity = new Field <DateTime?>(_context, nameof(LastActivity));
            _list         = new Field <List>(_context, nameof(List));
            _list.AddRule(NotNullRule <List> .Instance);
            Members = new MemberCollection(EntityRequestType.Card_Read_Members, () => Id, auth);
            _name   = new Field <string>(_context, nameof(Name));
            _name.AddRule(NotNullOrWhiteSpaceRule.Instance);
            _position = new Field <Position>(_context, nameof(Position));
            _position.AddRule(PositionRule.Instance);
            PowerUpData   = new ReadOnlyPowerUpDataCollection(EntityRequestType.Card_Read_PowerUpData, () => Id, auth);
            _shortId      = new Field <int?>(_context, nameof(ShortId));
            _shortUrl     = new Field <string>(_context, nameof(ShortUrl));
            Stickers      = new CardStickerCollection(() => Id, auth);
            _url          = new Field <string>(_context, nameof(Url));
            VotingMembers = new ReadOnlyMemberCollection(EntityRequestType.Card_Read_MembersVoted, () => Id, auth);

            TrelloConfiguration.Cache.Add(this);
        }