Пример #1
0
        /// <summary>
        /// Gets the links for work item revision.
        /// </summary>
        /// <typeparam name="TLinkCollection">The type of the t link collection.</typeparam>
        /// <param name="id">The identifier.</param>
        /// <param name="rev">The rev.</param>
        /// <param name="fromToken">From token.</param>
        /// <returns>Task&lt;TLinkCollection&gt;.</returns>
        public async Task <TLinkCollection> GetLinksForWorkItemRevision <TLinkCollection>(int id, int rev, Func <JArray, TLinkCollection> fromToken)
            where TLinkCollection : JsonLinkCollection
        {
            var exchange = StructuredHttpExchange.Get(WitRestCalls.Revision);

            exchange.SetRoute("{id}", id);
            exchange.SetRoute("{revisionNumber}", rev);
            exchange.SetQuery("$expand", "relations");


            TLinkCollection result = await ProcessCollectionRequest(exchange, o =>
            {
                JProperty rootToken = o.Properties().FirstOrDefault(p => p.Name == "relations");
                JArray values;
                if (rootToken != null)
                {
                    values = (JArray)rootToken.Value;
                }
                else
                {
                    values = new JArray();
                }
                TLinkCollection collection = JsonParsers.JArrayToInstance(values, fromToken);
                return(collection);
            });

            return(result);
        }