示例#1
0
        public CardContext(string id, TrelloAuthorization auth)
            : base(auth)
        {
            Data.Id = id;

            Actions                 = new ReadOnlyActionCollection(typeof(Card), () => Data.Id, auth);
            Actions.Refreshed      += (s, e) => OnMerged(new[] { nameof(Actions) });
            Attachments             = new AttachmentCollection(() => Data.Id, auth);
            Attachments.Refreshed  += (s, e) => OnMerged(new[] { nameof(Attachments) });
            CheckLists              = new CheckListCollection(() => Data.Id, auth);
            CheckLists.Refreshed   += (s, e) => OnMerged(new[] { nameof(CheckLists) });
            Comments                = new CommentCollection(() => Data.Id, auth);
            Comments.Refreshed     += (s, e) => OnMerged(new[] { nameof(Comments) });
            CustomFields            = new ReadOnlyCustomFieldCollection(() => Data.Id, auth);
            CustomFields.Refreshed += (s, e) => OnMerged(new[] { nameof(CustomFields) });
            Labels                   = new CardLabelCollection(this, auth);
            Labels.Refreshed        += (s, e) => OnMerged(new[] { nameof(Labels) });
            Members                  = new MemberCollection(() => Data.Id, auth);
            Members.Refreshed       += (s, e) => OnMerged(new[] { nameof(Members) });
            PowerUpData              = new ReadOnlyPowerUpDataCollection(EntityRequestType.Card_Read_PowerUpData, () => Data.Id, auth);
            PowerUpData.Refreshed   += (s, e) => OnMerged(new[] { nameof(PowerUpData) });
            Stickers                 = new CardStickerCollection(() => Data.Id, auth);
            Stickers.Refreshed      += (s, e) => OnMerged(new[] { nameof(Stickers) });
            VotingMembers            = new ReadOnlyMemberCollection(EntityRequestType.Card_Read_MembersVoted, () => Data.Id, auth);
            VotingMembers.Refreshed += (s, e) => OnMerged(new[] { nameof(VotingMembers) });

            BadgesContext = new BadgesContext(Auth);

            Data.Badges = BadgesContext.Data;
        }
示例#2
0
        protected override IEnumerable <string> MergeDependencies(IJsonCard json, bool overwrite)
        {
            var properties = BadgesContext.Merge(json.Badges, overwrite)
                             .Select(p => $"{nameof(Card.Badges)}.{p}")
                             .ToList();

            if (json.Actions != null)
            {
                Actions.Update(json.Actions.Select(a => a.GetFromCache <Action, IJsonAction>(Auth, overwrite)));
                properties.Add(nameof(Card.Actions));
            }
            if (json.Attachments != null)
            {
                Attachments.Update(json.Attachments.Select(a => a.TryGetFromCache <Attachment, IJsonAttachment>(overwrite) ?? new Attachment(a, Data.Id, Auth)));
                properties.Add(nameof(Card.Attachments));
            }
            if (json.CheckLists != null)
            {
                CheckLists.Update(json.CheckLists.Select(a => a.GetFromCache <CheckList, IJsonCheckList>(Auth, overwrite)));
                properties.Add(nameof(Card.CheckLists));
            }
            if (json.Comments != null)
            {
                Comments.Update(json.Comments.Select(a => a.GetFromCache <Action, IJsonAction>(Auth, overwrite)));
                properties.Add(nameof(Card.Comments));
            }
            if (json.CustomFields != null)
            {
                CustomFields.Update(json.CustomFields.Select(a => a.GetFromCache <CustomField, IJsonCustomField>(Auth, overwrite, Data.Id)));
                properties.Add(nameof(Card.CustomFields));
            }
            if (json.Labels != null)
            {
                Labels.Update(json.Labels.Select(a => a.GetFromCache <Label, IJsonLabel>(Auth, overwrite)));
                properties.Add(nameof(Card.Labels));
            }
            if (json.Members != null)
            {
                Members.Update(json.Members.Select(a => a.GetFromCache <Member, IJsonMember>(Auth, overwrite)));
                properties.Add(nameof(Card.Members));
            }
            if (json.PowerUpData != null)
            {
                PowerUpData.Update(json.PowerUpData.Select(a => a.GetFromCache <PowerUpData, IJsonPowerUpData>(Auth, overwrite)));
                properties.Add(nameof(Card.PowerUpData));
            }
            if (json.Stickers != null)
            {
                Stickers.Update(json.Stickers.Select(a => a.TryGetFromCache <Sticker, IJsonSticker>(overwrite) ?? new Sticker(a, Data.Id, Auth)));
                properties.Add(nameof(Card.Stickers));
            }
            if (json.MembersVoted != null)
            {
                VotingMembers.Update(json.MembersVoted.Select(a => a.GetFromCache <Member, IJsonMember>(Auth, overwrite)));
                properties.Add(nameof(Card.VotingMembers));
            }

            return(properties);
        }
示例#3
0
 public CardContext(string id, TrelloAuthorization auth)
     : base(auth)
 {
     Data.Id       = id;
     BadgesContext = new BadgesContext(Auth);
     BadgesContext.SynchronizeRequested += () => Synchronize();
     Data.Badges = BadgesContext.Data;
 }