Exemple #1
0
        public async Task <IReadOnlyList <T> > WiqlQuery <T>(string wiql, bool fullyPopulate, Func <JToken, T> fromToken) where T : JsonWorkItem
        {
            const string format   = " \"query\": \"{0}\" ";
            string       body     = "{" + String.Format(format, wiql) + "}";
            var          exchange = StructuredHttpExchange.Post("/wit/wiql", body);

            JsonParsers.QueryResult <T> result = await ProcessCollectionRequest(exchange, o => JsonParsers.WiqlQueryParse(o, fromToken));

            var retVal = new List <T>();

            if (fullyPopulate)
            {
                List <int> ids = result.Items.Select(workItem => workItem.Id).ToList();
                Task <IReadOnlyList <T> > populated = JsonWorkItemsLoader(ids, result.TimeStamp, fromToken);
                retVal.AddRange(populated.Result);
            }
            else
            {
                foreach (T item in result.Items)
                {
                    retVal.Add(item);
                }
            }
            return(retVal);
        }
Exemple #2
0
        /// <summary>
        ///     Creates the room.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <returns>Task&lt;ITeamRoom&gt;.</returns>
        public async Task <ITeamRoom> CreateRoom(string name, string description)
        {
            const string format   = " \"name\": \"{0}\", \"description\": \"{1}\", ";
            string       body     = "{" + String.Format(format, name, description) + "}";
            var          exchange = StructuredHttpExchange.Post("/chat/rooms", body);
            ITeamRoom    result   = await ProcessCollectionRequest(exchange, o => JsonParsers.JObjectToInstance(o, TeamRoomImpl.FromToken));

            return(result);
        }
Exemple #3
0
        /// <summary>
        ///     Gets the changesets batch.
        /// </summary>
        /// <param name="ids">The ids.</param>
        /// <returns>Task&lt;IReadOnlyList&lt;JsonChangeSet&gt;&gt;.</returns>
        public async Task <IReadOnlyList <JsonChangeSet> > GetChangesetsBatch(List <int> ids)
        {
            var json  = new JObject();
            var array = new JArray();

            foreach (int id in ids)
            {
                array.Add(id);
            }
            json.Add("changesetIds", array);
            json.Add("commentLength", 255);
            string body = json.ToString();
            StructuredHttpExchange        exchange = StructuredHttpExchange.Post(TfvcRestCalls.ChangesetsBatch, body);
            IReadOnlyList <JsonChangeSet> result   = await ProcessCollectionRequest(exchange, o => JsonParsers.ValuesToObjects(o, JsonChangeSet.FromToken));

            return(result);
        }
        public void Post_UnitTest()
        {
            String relativeRoute           = default(String);
            String body                    = default(String);
            StructuredHttpExchange _retVal = default(StructuredHttpExchange);

            ExecuteMethod(
                () => { return(GetInstance()); },
                instance =>
            {
                relativeRoute = default(String); //No Constructor
                body          = default(String); //No Constructor
                Post_PreCondition(ref instance, ref relativeRoute, ref body);
            },
                instance => { _retVal = StructuredHttpExchange.Post(relativeRoute, body); },
                instance => { Post_PostValidate(instance, relativeRoute, body, _retVal); });
        }