예제 #1
0
        public static void ProductsRequested(string response)
        {
            if (response != null && !response.Equals("[]"))
            {
                IDictionary theProductsRequestResponse = Json.Deserialize((string)response) as IDictionary;

                bool   success  = (bool)theProductsRequestResponse["success"];
                String message  = theProductsRequestResponse["message"] as String;
                IList  products = theProductsRequestResponse["products"] as IList;

                IDictionary <string, Product> theProducts = new Dictionary <string, Product>();

                for (int i = 0; i < products.Count; i++)
                {
                    IDictionary product = (IDictionary)products[i];
                    theProducts[(string)product["identifier"]] = new Product((string)product["identifier"],
                                                                             (string)product["description"],
                                                                             (string)product["priceLocale"]);
                }

                _productsRequestResponse = new ProductsRequestResponse(success, message, theProducts);
            }
        }
예제 #2
0
        public static void ProductsRequested(string response)
        {
            if (response != null &&  !response.Equals("[]") ) {

                IDictionary theProductsRequestResponse = Json.Deserialize((string) response) as IDictionary;

                bool success = (bool)theProductsRequestResponse["success"];
                String message = theProductsRequestResponse["message"] as String;
                IList products = theProductsRequestResponse["products"] as IList;

                IDictionary<string, Product> theProducts = new Dictionary<string,Product>();

                for(int i = 0; i < products.Count; i++) {
                    IDictionary product = (IDictionary) products[i];
                    theProducts[(string) product["identifier"]] = new Product((string) product["identifier"],
                                                                                            (string) product["description"],
                                                                                            (string) product["priceLocale"]);
                }

                _productsRequestResponse = new ProductsRequestResponse(success,message,theProducts);
            }
        }