Beispiel #1
0
        public async Task <List <Recipe> > CallService()
        {
            var httpClient = new HttpClient(new HttpLoggingHandler())
            {
                BaseAddress = new Uri("http://www.recipepuppy.com")
            };

            var api = RestService.For <IRecipePuppy>(httpClient /*, new RefitSettings
                                                                 * {
                                                                 * JsonSerializerSettings = new JsonSerializerSettings()
                                                                 * {
                                                                 * ContractResolver = new CamelCasePropertyNamesContractResolver()
                                                                 * }
                                                                 * }*/);

            /*
             * /*
             * api.GetRecipeListJson("pizza", "1").ContinueWith((arg) =>
             * {
             *  Debug.Write("*************** " + arg.Result);
             * });*/

            RecipeResponse recipeResponse = await api.GetRecipeList("pizza", "1");

            return(ConvertResponse(recipeResponse));
        }
Beispiel #2
0
        private List <Recipe> ConvertResponse(RecipeResponse recipeResponse)
        {
            List <Recipe> recipes = new List <Recipe>();

            foreach (Item item in recipeResponse.Items)
            {
                recipes.Add(new Recipe(item.title));
            }
            return(recipes);
        }