Пример #1
0
        public static API.ANet.Recipe GetANetRecipe(int recipe_id, string lang)
        {
            API.ANet.Recipe recipe = null;
            try
            {
                recipe = DataProvider <API.ANet.Recipe> .GetData(
                    String.Format("https://api.guildwars2.com/v1/recipe_details.json?recipe_id={0}&lang={1}", recipe_id, lang));
            }
            catch (Exception ex)
            {
                if (recipe == null)
                {
                    recipe           = new API.ANet.Recipe();
                    recipe.recipe_id = recipe_id.ToString();
                    recipe.error     = Config.DEFAULT_ERROR_CODE;
                    recipe.text      = ex.Message;
                }
            }
            if (recipe.error == null)
            {
                API.ANet.Item item           = null;
                string        output_item_id = recipe.output_item_id;
                try
                {
                    // get correspondig item
                    item = GetANetItem(int.Parse(output_item_id), lang);
#if DEBUG
                    if (!API.ANet.ItemType.Values.Contains(item.type))
                    {
                        Console.WriteLine("New item type \"{0}\": {1}", item.type, output_item_id);
                    }
#endif
                    foreach (API.ANet.Ingredient ingredient in recipe.ingredients)
                    {
                        API.ANet.Item item2 = null;
                        try
                        {
                            item2 = GetANetItem(int.Parse(ingredient.item_id), lang);
                        }
                        catch (Exception ex)
                        {
                            if (item2 == null)
                            {
                                item2         = new API.ANet.Item();
                                item2.item_id = ingredient.item_id;
                                item2.error   = Config.DEFAULT_ERROR_CODE;
                                item2.text    = ex.Message;
                            }
                        }
                        finally
                        {
                            if (item2 != null)
                            {
                                ingredient.Item = item2;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    if (item == null)
                    {
                        item         = new API.ANet.Item();
                        item.item_id = output_item_id;
                        item.error   = Config.DEFAULT_ERROR_CODE;
                        item.text    = ex.Message;
                    }
                }
                finally
                {
                    if (recipe != null && item != null)
                    {
                        recipe.Item = item;
                    }
                }
            }
            return(recipe);
        }
Пример #2
0
 public Item(API.ANet.Item item)
 {
     this._item = item;
 }
Пример #3
0
 public Ingredient(API.ANet.Item item, int count)
 {
     this._item  = item;
     this._count = count;
 }