Example #1
0
 private IEquation MapJsonToDto(PyEquationJson equationJson, int equationType)
 {
     if (equationType == 1)
     {
         var sv = new SeparableVariables();
         sv.Equation      = equationJson.LeftSide + " = " + equationJson.RightSide;
         sv.EquationLatex = equationJson.EquationLatex;
         sv.Solution      = equationJson.Solution;
         sv.SolutionLatex = equationJson.SolutionLatex;
         return(sv);
     }
     else if (equationType == 2)
     {
         var hg = new Homogeneous();
         hg.Equation      = equationJson.LeftSide + " = " + equationJson.RightSide;
         hg.EquationLatex = equationJson.EquationLatex;
         hg.Solution      = equationJson.Solution;
         hg.SolutionLatex = equationJson.SolutionLatex;
         return(hg);
     }
     else
     {
         throw new NotImplementedException($"equationType {equationType} is not supported for mapping");
     }
 }
Example #2
0
        private PyEquationJson MapDtoToJson(IEquation dtoEquation)
        {
            var jsonEquation = new PyEquationJson();
            var sides        = dtoEquation.Equation.Split('=');

            jsonEquation.LeftSide  = sides[0];
            jsonEquation.RightSide = sides[1];
            return(jsonEquation);
        }
Example #3
0
        public async Task <PyEquationJson> SolveEquation(PyEquationJson equation)
        {
            var client             = new RestClient("http://127.0.0.1:5050/");
            var jsonEquationString = JsonConvert.SerializeObject(equation);
            var request            = new RestRequest("solve", Method.POST);

            request.RequestFormat = DataFormat.Json;
            request.AddJsonBody(jsonEquationString);

            var response = await client.ExecuteAsync(request);

            if (response.ResponseStatus == ResponseStatus.Completed)
            {
                return(JsonConvert.DeserializeObject <PyEquationJson>(response.Content));
            }
            return(null);
        }