Example #1
0
        public async Task<IList<Torrent>> GetTorrents(Filter filter = Filter.All, string category = null)
        {
            await CheckAuthentification();

            var keyValuePairs = new KeyValuePair<string, string>[2];
            keyValuePairs.SetValue(new KeyValuePair<string, string>("filter", filter.ToString().ToLower()), 0);


            if (category != null)
            {
                keyValuePairs.SetValue(new KeyValuePair<string, string>("category", category), 1);
            }

            HttpContent content = new FormUrlEncodedContent(keyValuePairs);

            var uri = new Uri("/query/torrents?" + await content.ReadAsStringAsync(), UriKind.Relative);
            var response = await _httpClient.GetAsync(uri);
            var jsonStr = await response.Content.ReadAsStringAsync();
            return JsonConvert.DeserializeObject<IList<Torrent>>(jsonStr);
        }
Example #2
0
        /// <summary>
        /// Parse an KeyValuePair
        /// </summary>
        /// <returns>Parsed KeyValuePair</returns>
        public KeyValuePair ParseKeyValuePair()
        {
            KeyValuePair keyValuePair = new KeyValuePair();

            //Get key
            CurrentToken = TokenStream.NextToken();
            keyValuePair.SetKey(CurrentToken.GetValue().ToString());

            //Skip :
            NextToken(":", "key : value", ':');

            //Get value
            keyValuePair.SetValue(ParseExpression());

            return keyValuePair;
        }