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); /* * * IList products = Json.Deserialize((string) response) as D; * * for(int i = 0; i < products.Count; i++) { * IDictionary product = (IDictionary) products[i]; * _productsResponse[(string) product["identifier"]] = new ProductResponse((string) product["identifier"], * (string) product["description"], * (string) product["priceLocale"]); * } */ } }
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); /* IList products = Json.Deserialize((string) response) as D; for(int i = 0; i < products.Count; i++) { IDictionary product = (IDictionary) products[i]; _productsResponse[(string) product["identifier"]] = new ProductResponse((string) product["identifier"], (string) product["description"], (string) product["priceLocale"]); } */ } }