Пример #1
0
        private async Task <Testcase> GetTestcaseAsync(int i, int serial)
        {
            Testcase testcase = new Testcase();

            if (isSample)
            {
                testcase.Serial    = samples[i].Serial;
                testcase.ProblemId = samples[i].ProblemId;
                testcase.In        = samples[i].In;
                testcase.Out       = samples[i].Out;
            }
            else
            {
                testcase = await HttpClientManager.ExecuteGetJsonAsync <Testcase>(string.Format(FIND_BY_PROBLEM_ID_TESTCASE, probrem.id, serial));

                if (testcase.In.Contains("(terminated because of the limitation)"))
                {
                    testcase.In = await HttpClientManager.ExecuteGetStringAsync(string.Format(FIND_BY_PROBLEM_ID_TESTCASE_ALT_IN, probrem.id, serial));
                }
                if (testcase.Out.Contains("(terminated because of the limitation)"))
                {
                    testcase.Out = await HttpClientManager.ExecuteGetStringAsync(string.Format(FIND_BY_PROBLEM_ID_TESTCASE_ALT_OUT, probrem.id, serial));
                }
            }
            return(testcase);
        }
Пример #2
0
        private async void BtnConnect_ClickAsync(object sender, EventArgs e)
        {
            if (txtNo.Text == string.Empty)
            {
                return;
            }
            ClearDisplayArea();

            probrem = await HttpClientManager.ExecuteGetXMLAsync <Probrem>(string.Format(API_AOJ_OLD, ID));

            probrem.id   = probrem.id.Replace("\n", string.Empty);
            probrem.name = probrem.name.Replace("\n", string.Empty);

            var responce2 = await HttpClientManager.ExecuteGetJsonAsync <Probrem2>(string.Format(API_AOJ_NEW, ID));

            var parser = new HtmlParser();
            var doc    = parser.ParseDocument(responce2.html);

            txtTitle.Text = string.Format("AOJ {0} ({1} : {2})", ID, probrem.name, doc.QuerySelectorAll("h1")[0].TextContent);

            string text = "";

            using (StreamReader sr = new StreamReader("ContentsTemplate.txt", Encoding.GetEncoding("UTF-8")))
            {
                text = sr.ReadToEnd();
            }
            txtContents.Text = string.Format(text, ID);
        }
Пример #3
0
        private async Task <TestcaseHeader> GetTestcaseHeaderAsync()
        {
            testcaseHeader = new TestcaseHeader();
            if (isSample)
            {
                samples = await HttpClientManager.ExecuteGetJsonAsync <Sample[]>(string.Format(FIND_BY_PROBLEM_ID_SAMPLES, probrem.id));

                return(ConvertSamplesToTestcaseHeader());
            }
            else
            {
                return(await HttpClientManager.ExecuteGetJsonAsync <TestcaseHeader>(string.Format(FIND_BY_PROBLEM_ID_TESTCASE_HEADER, probrem.id)));
            }
        }