如何使用Trello.Net创建IAttachmentID?

时间:2013-01-21 19:23:44

标签: c# api attachment trello trello.net

我正在使用dillenmeister的Trello.Net API包装器,我发现几个月前添加了从卡中删除附件,但我正在使用的调用(Trello.Cards.RemoveAttachment())需要{ {1}}和CardId。我已经弄清楚如何创建IAttachmentIdCardId),但我没有看到如何创建它正在寻找的new CardID(Card.ID)

我有附件对象,可以从那里获取IAttachmentID,但这是字符串类型。

1 个答案:

答案 0 :(得分:1)

Attachment类本身实现了IAttachmentId

// Example: Remove all attachments with the name "DevSupport" from a card 
var card = trello.Cards.WithId("a card id");
foreach (var attachment in card.Attachments.Where(a => a.Name == "DevSupport"))
    trello.Cards.RemoveAttachment(card, attachment);

它与许多其他对象类似,例如Card类实现ICardId。如果您有CardId,则无需创建Card对象。只需使用实际的Card

// Example: Fetch all members assigned to a card
var card = trello.Cards.WithId("a card id");
var members = trello.Members.ForCard(card);

尽管如此,可能还需要AttachmentId课程。你的用例是什么?