Beispiel #1
0
        /// <summary>
        /// Converts GDLE recipe + precursors to ACE recipe + cookbooks
        /// </summary>
        public static bool TryConvert(Models.RecipeCombined input, out List <CookBook> cookbooks, out Recipe recipe)
        {
            if (!TryConvert(input.recipe, out recipe))
            {
                cookbooks = null;
                return(false);
            }

            recipe.Id = input.key;

            cookbooks = new List <CookBook>();

            foreach (var precursor in input.precursors)
            {
                if (!TryConvert(precursor, out var cookbook))
                {
                    return(false);
                }

                cookbook.RecipeId = input.key;

                cookbooks.Add(cookbook);
            }
            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// Converts ACE recipe + cookbooks to GDLE recipe + precursors
        /// </summary>
        public static bool TryConvert(List <CookBook> cookbooks, out Models.RecipeCombined result)
        {
            if (cookbooks == null || cookbooks.Count == 0)
            {
                result = null;
                return(false);
            }

            var recipe = cookbooks[0].Recipe;

            result = new Models.RecipeCombined();

            result.key  = recipe.Id;
            result.desc = cookbooks[0].SourceWCID.ToString();   // TODO: get weenie name

            TryConvert(recipe, out var newRecipe);
            if (newRecipe != null)
            {
                newRecipe.RecipeId = 0;
            }

            result.recipe = newRecipe;

            result.precursors = new List <Models.RecipePrecursor>();
            foreach (var cookbook in cookbooks)
            {
                if (TryConvert(cookbook, out var precursor))
                {
                    precursor.RecipeId = null;
                    result.precursors.Add(precursor);
                }
            }
            return(true);
        }
Beispiel #3
0
        public static bool TryLoadRecipeCombined(string[] lines, out Models.RecipeCombined result)
        {
            try
            {
                result = JsonConvert.DeserializeObject <Models.RecipeCombined>(string.Join("\n", lines));

                return(true);
            }
            catch
            {
                result = null;
                return(false);
            }
        }
Beispiel #4
0
        public static bool TryLoadRecipeCombined(string file, out Models.RecipeCombined result)
        {
            try
            {
                var fileText = File.ReadAllText(file);

                result = JsonConvert.DeserializeObject <Models.RecipeCombined>(fileText);

                return(true);
            }
            catch
            {
                result = null;
                return(false);
            }
        }