예제 #1
0
        public async Task <HashSet <string> > QueryArray(string query)
        {
            Dictionary <string, string> content = new Dictionary <string, string> {
                { query, null }
            };
            FormUrlEncodedContent encodedContent = new FormUrlEncodedContent(content);

            HttpResponseMessage response = await Client.PostAsync(ApiUrl + "query", encodedContent);

            if (response.IsSuccessStatusCode)
            {
                ArrayResult jsonObject = JsonConvert.DeserializeObject <ArrayResult>(await response.Content.ReadAsStringAsync());
                if (jsonObject.code > 0)
                {
                    HashSet <string> buffer = new HashSet <string>();

                    for (int i = 0; i < jsonObject.content.Length; i++)
                    {
                        buffer.Add(NormalizePath(jsonObject.content[i]));
                    }

                    return(buffer);
                }
            }

            return(null);
        }
예제 #2
0
        public async Task <Tuple <IEnumerable <Package>, HashSet <int> > > ValidateCache(Dictionary <int, int> localVersions)
        {
            MultipartFormDataContent content = new MultipartFormDataContent {
                { new StringContent(JsonConvert.SerializeObject(localVersions)), "validateCache" }
            };

            HttpResponseMessage response = await Client.PostAsync(ApiUrl + "query", content);

            if (response.IsSuccessStatusCode)
            {
                ArrayResult <QueryContent> jsonObject = JsonConvert.DeserializeObject <ArrayResult <QueryContent> >(await response.Content.ReadAsStringAsync());
                if (Utils.IsSuccessStatusCode(jsonObject.code))
                {
                    List <Package> pkgs           = new List <Package>();
                    HashSet <int>  remoteVersions = new HashSet <int>();
                    foreach (QueryContent qc in jsonObject.content)
                    {
                        pkgs.Add(new Package(qc));
                        remoteVersions.Add(qc.id);
                    }
                    return(new Tuple <IEnumerable <Package>, HashSet <int> >(pkgs, remoteVersions));
                }
            }

            return(new Tuple <IEnumerable <Package>, HashSet <int> >(new Package[0], new HashSet <int>()));
        }
예제 #3
0
        public static async Task <IEnumerable <Package> > ReportDLC(List <SteamManager.DLC> dlcList, string token, Uri apiUrl)
        {
            StringContent       encodedContent = new StringContent(JsonConvert.SerializeObject(new ReportDLCcontent(token, dlcList)), Encoding.UTF8, "application/json");
            HttpResponseMessage response       = await Client.PostAsync(apiUrl + "reportDLC", encodedContent);

            if (response.IsSuccessStatusCode)
            {
                ArrayResult <QueryContent> jsonObject = JsonConvert.DeserializeObject <ArrayResult <QueryContent> >(await response.Content.ReadAsStringAsync());
                if (Utils.IsSuccessStatusCode(jsonObject.code))
                {
                    List <Package> pkgs = new List <Package>();
                    foreach (QueryContent qc in jsonObject.content)
                    {
                        pkgs.Add(new Package(qc));
                    }
                    return(pkgs);
                }
            }

            return(new Package[0]);
        }