Esempio n. 1
0
        private static WebFormatter privGetInstance()
        {
            if (instance == null)
            {
                instance = new WebFormatter();
            }

            return(instance);
        }
Esempio n. 2
0
        static void Run()
        {
            string jsonData;

            WebFormatter.GetJSONFromURL("http://apitest.sertifi.net/api/Students", out jsonData);

            ErrorCode          retCode;
            List <StudentData> students;

            retCode = JSONParser.ReadJSONData(jsonData, out students);
            Debug.Assert(retCode == ErrorCode.SUCCESS); //safety

            JSONParser.dump(students);

            StudentAggregateParser pSAggregate = new StudentAggregateParser(students);

            pSAggregate.Process();
        }
Esempio n. 3
0
        public void Process()
        {
            StudentAggregate aggregregate = new StudentAggregate
            {
                YourEmail = "*****@*****.**", //hard-coded for requirements
                YourName  = "Rodolfo Gomez",            //hard-coded for requirements
                YearWithHighestAttendance     = privFindYearWithHighestAttendance(),
                YearWithHighestOverallGpa     = privFindYearWithHighestOverallGpa(),
                Top10StudentIdsWithHighestGpa = privFindTop10StudentIdsWithHighestGpa(),
                StudentIdMostInconsistent     = privFindStudentIdMostInconsistent()
            };

            string jsonOutput = JsonConvert.SerializeObject(aggregregate, Formatting.Indented);
            string response;

            WebFormatter.UploadJSONToURL(jsonOutput, "http://apitest.sertifi.net/api/StudentAggregate", out response);

            Console.WriteLine("Uploaded Data to Server, Response Received: {0}", response);

            dump(jsonOutput);
        }
Esempio n. 4
0
        public static void UploadJSONToURL(string data, string address, out string response)
        {
            WebFormatter pWeb = privGetInstance();

            pWeb.privUploadJSONToURL(address, data, out response);
        }
Esempio n. 5
0
        public static void GetJSONFromURL(string url, out string data)
        {
            WebFormatter pWeb = privGetInstance();

            pWeb.privGetJSONFromURL(url, out data);
        }