Exemplo n.º 1
0
        private static void ParseItems(string itemFile, string outputFolder)
        {
            using (StreamReader reader = new StreamReader(itemFile))
            {
                RawItems       rawItems       = RawItems.FromJson(reader.ReadToEnd());
                ProcessedItems processedItems = new ProcessedItems();

                foreach (RawItem rawItem in rawItems.Items)
                {
                    if (rawItem.Price < 0)
                    {
                        continue;
                    }

                    rawItem.Category = RecategorizeItem(rawItem);

                    ProcessedItem processedItem = ProcessedItem.FromRawItem(rawItem);
                    processedItems.Items.Add(processedItem);
                }

                processedItems.Sort();

                string outputFileItems = Path.Combine(outputFolder, "StoreItems.json");

                GenerateItemsOutput(processedItems, outputFileItems);
            }
        }
Exemplo n.º 2
0
        private static void GenerateItemsOutput(ProcessedItems items, string outputFile)
        {
            Directory.CreateDirectory(Path.GetDirectoryName(outputFile));

            using (StreamWriter writer = new StreamWriter(outputFile))
            {
                writer.WriteLine(items.ToJson());
            }
        }