예제 #1
0
        public Dictionary <string, object> processResult(string method, EgoiMap arguments)
        {
            string payload         = buildPayload(method, arguments);
            string json            = fetchResponse(payload);
            JavaScriptSerializer s = new JavaScriptSerializer();

            /**
             * IT's A TRAP!
             */
            Dictionary <string, object> response = s.Deserialize <Dictionary <string, object> >(json);
            Dictionary <string, object> r2       = response["Egoi_Api"] as Dictionary <string, object>;
            Dictionary <string, object> map      = r2[method] as Dictionary <string, object>;

            //IF ERROR EXIST
            if (map.ContainsKey("ERROR"))
            {
                throw new EgoiException(EgoiException.idToMessage(map["ERROR"] as string));
            }

            //IF ERROR NOT EXIST AND RESPONSE NOT EXIST
            if (!map.ContainsKey("response"))
            {
                throw new EgoiException(EgoiException.idToMessage(""));
            }


            // Status not used
            map.Remove("status");

            return(map);
        }
예제 #2
0
        private void checkResult(object result)
        {
            if (result == null)
            {
                throw new EgoiException("The response from the server was null");
            }

            if (result is string)
            {
                throw new EgoiException(EgoiException.idToMessage(result as string));
            }
        }
예제 #3
0
        public Dictionary <string, object> processResult(string method, EgoiMap arguments)
        {
            string url             = buildUrl(method, arguments);
            string json            = fetchResponse(url);
            JavaScriptSerializer s = new JavaScriptSerializer();

            /**
             * IT's A TRAP!
             */
            Dictionary <string, object> response = s.Deserialize <Dictionary <string, object> >(json);
            Dictionary <string, object> r2       = response["Egoi_Api"] as Dictionary <string, object>;
            Dictionary <string, object> map      = r2[method] as Dictionary <string, object>;

            if (map.ContainsKey("response"))
            {
                throw new EgoiException(EgoiException.idToMessage(map["response"] as string));
            }

            // Status not used
            map.Remove("status");

            return(map);
        }