Esempio n. 1
0
        async Task <IReadOnlyList <RelationLinks> > InternalGetRelatedIdsAsync(int id, string relationshipType, DateTime?asOf, CancellationToken cancellationToken)
        {
            var list = new List <RelationLinks>();

            using var mc = log?.Enter(LogLevel.RawApis, new object[] { id, null, asOf, WorkItemExpand.Relations, null, cancellationToken }, "GetWorkItemsAsync");

            var workItem = await WorkItemClient.GetWorkItemAsync(id, null, asOf, WorkItemExpand.Relations, userState : null, cancellationToken)
                           .ConfigureAwait(false);

            if (workItem.Relations != null)
            {
                list.AddRange(workItem.Relations
                              .Where(r => relationshipType == null || r.Rel == relationshipType)
                              .Select(r => new RelationLinks {
                    Title               = r.Title,
                    Attributes          = r.Attributes,
                    Type                = FindRelationship(r.Rel),
                    RelatedId           = ParseIdFromRelationship(r.Url),
                    RawRelationshipType = r.Rel,
                    Url = r.Url
                }));
            }

            return(list);
        }