Example #1
0
        public async void EqualRequest(EqualExpression equalExpression, Form1 form)
        {
            JsonBuilder jsonBuilder = new JsonBuilder();
            string      jsonString  = jsonBuilder.SetObjectValue(NUMBER_STRING, equalExpression.Number)
                                      .SetObjectValue(RIGHTBRACKET_STRING, equalExpression.RightBracket)
                                      .ToString();

            var uri = "http://localhost:" + PORT + "/api/getanswer/1";

            var request = new HttpRequestMessage
            {
                Method     = HttpMethod.Post,
                RequestUri = new Uri(uri),
                Content    = new StringContent(jsonString, Encoding.UTF8, "application/json")
            };

            HttpResponseMessage response = await Client.SendAsync(request);

            response.EnsureSuccessStatusCode();

            var result = await response.Content.ReadAsStringAsync();

            if (decimal.TryParse(result, out decimal d))
            {
                form.SubPanelShow(result);
            }
            else
            {
                form.SubPanelShow("運算式錯誤");
            }
        }
Example #2
0
        public EqualExpression GenerateCurrentEqualExpression()
        {
            decimal.TryParse(NumberStr, out decimal number);
            var equalExpression = new EqualExpression(number: number, rightBracket: RightBracket);

            InitThis();
            return(equalExpression);
        }